Played with the code for hours and just got it to work, 20 minutes after
posting here. ruby-forum.com brought me luck, thank you :)
Here the working code:
<% if current_user.favourites.exists? :post_id => @post.id %>
So it checks the favs of the current_user in the fawvourites table and
compares the post_id ( which is the id of the already faved post) to the
current post that is displayed on the page.
Hope this helps someone else too :)
--
Posted via http://www.ruby-forum.com/.
--
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.
No comments:
Post a Comment