Ive got a like and video model. On a Video page, Users can click a link ("like") button which will allow them to like a particular video. Since my like button/image comes in the form of a link and not an actual html form. How should this be implemented? Do I need to specify a ":method => puts" in my link_to tag helper? What are your thoughts? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
AJAX - set the onClick property to point to a function that sends the request to the server. On Mon, Oct 18, 2010 at 7:25 AM, Christian Fazzini < christian.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ive got a like and video model. > > On a Video page, Users can click a link ("like") button which will > allow them to like a particular video. > > Since my like button/image comes in the form of a link and not an > actual html form. How should this be implemented? Do I need to specify > a ":method => puts" in my link_to tag helper? > > What are your thoughts? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ajax is how I am definitely going to implement this with. However, I need to how to do this without js first. On Oct 18, 7:31 pm, Brett Thomas <brettptho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> AJAX - set the onClick property to point to a function that sends the > request to the server. > > On Mon, Oct 18, 2010 at 7:25 AM, Christian Fazzini < > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Ive got a like and video model. > > > On a Video page, Users can click a link ("like") button which will > > allow them to like a particular video. > > > Since my like button/image comes in the form of a link and not an > > actual html form. How should this be implemented? Do I need to specify > > a ":method => puts" in my link_to tag helper? > > > What are your thoughts? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Is it possible for a link to point to the ''create'' method of a controller, passing the necessary values/attributes ? Or is the only way to do such a thing, through an html form (via post)? On Oct 18, 7:42 pm, Christian Fazzini <christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ajax is how I am definitely going to implement this with. > > However, I need to how to do this without js first. > > On Oct 18, 7:31 pm, Brett Thomas <brettptho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > AJAX - set the onClick property to point to a function that sends the > > request to the server. > > > On Mon, Oct 18, 2010 at 7:25 AM, Christian Fazzini < > > > christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Ive got a like and video model. > > > > On a Video page, Users can click a link ("like") button which will > > > allow them to like a particular video. > > > > Since my like button/image comes in the form of a link and not an > > > actual html form. How should this be implemented? Do I need to specify > > > a ":method => puts" in my link_to tag helper? > > > > What are your thoughts? > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Assuming you have the following models: User, Video, Like. If a Like instance belongs to a video and a user. You could use nested routes in the following format: resources :video do resource :like end Which gives you the following URLS: /videos/1/like /videos/1/like/1 So then using the proper path and action, you can easily create a link to "like" a video. link_to("Like!", video_like_path(video), :action => :post) Then in your Like controller (create method), you simply have to create and save Like instance. That should be enough to get you going in the right direction. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for that Tim On Oct 18, 8:51 pm, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> Assuming you have the following models: User, Video, Like. If a Like > instance belongs to a video and a user. You could use nested routes in > the following format: > > resources :video do > resource :like > end > > Which gives you the following URLS: > > /videos/1/like > /videos/1/like/1 > > So then using the proper path and action, you can easily create a link > to "like" a video. > > link_to("Like!", video_like_path(video), :action => :post) > > Then in your Like controller (create method), you simply have to > create and save Like instance. > > That should be enough to get you going in the right direction.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.