First I want to thank the community for their help and here is my
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 %>
already faved<% 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.