Im trying to display recently added comments from tattoos posted by the user. So, if I posted a tattoo and then user_b sent โhey, I like your tattooโ, then I am trying to get only a comment.
First of all, I use the action_as_commentable_with_threading gem, which does not create a foreign key for the im table trying to join. Therefore, my controller cannot search for tattoo_id, it must search for commentable_id
In the controller, I would have to call the Comment model and then pass some SQL materials to it, but apparently I donโt know how to pass custom SQL queries to ruby, because even my query string works in the terminal, I get all kinds of nonsense when trying to use it on rails.
Im basically trying to do this:
SELECT comments.id FROM comments,tattoos WHERE commentable_id = tattoos.id AND tattoos.member_id =
where # {current_user} will be passed to current_user.
source share