First I want to thank the community for their help and here is my
question :)

I have a simple add to fdavourites functionality. A user can add a post
to their favouirites. Thing is I want to display the "add to favourites"
button if the post is not in the user's favs and something else if it
is, so I need to check for this in the view.

favourites table has post_id and user_id

I tried something like

<% if current_user.favourites.exists? @post, :post_id %>
  <p>already faved</p>
<% else %>
  blabla not faved :)
<% end %>

I'm pretty sure the error is in the  "@post, :post_id" part of my code
but I couldn't find anything about the .exists? syntax in google.

Thanks again

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to