[Rails] Re: How to create a "like" button
Thanks for that Tim
On Oct 18, 8:51 pm, Tim Shaffer <timshaf...@me.com> 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@googlegroups.com.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home