I'm using the devise
and acts_as_votable
gems to allow users to cast their votes on posts. My current objective is to query a list of the posts liked by the user.
Looking around in the Rails console I found out that when a post is voted on a votes_for
table gets appended on containing information like the timestamp, vote weight and the voter_id
which is what I would like to call upon.
Here's what the user
controller looks like (user
controller because I'm attempting to query the likes on the users/show
page):
@user = current_user
@links = Link.all
@likes = @links.where.votes_for(:voter_id => @user.id) // line I'm trying to figure out, I reckon it'd look something like this
I could definitely be going about this the wrong way altogether, if that's the case I'd just appreciate some direction.
Explanation would be appreciated... I'm learning the fundamentals of Rails and finding its naming conventions convoluted and hard to follow.