ahnbizcad
ahnbizcad

Reputation: 10807

Check if voted for scope - acts as votable

The acts_as_votable gem allows you to check if a user voted for a votable model. https://github.com/ryanto/acts_as_votable

user.voted_on?(@votable)

The gem also allows you to cast votes using a scope

user.vote(@votable), vote_scope: 'funny' user.vote(@votable), vote_scope: 'useful'

I was wondering how to check if a user voted on an object, but only in a specific scope.

I imagine the code to be something like

user.voted_on? @votable, vote_scope: 'funny'

Is this possible with this gem?

Upvotes: 1

Views: 772

Answers (1)

infused
infused

Reputation: 24347

Yes, your example syntax is correct:

user.voted_on? @votable, vote_scope: 'funny'

The voted_on? and voted_for? methods accept :vote_scope as an option.

Upvotes: 2

Related Questions