Closed ghost closed 11 years ago
Thanks, thats a documentation bug. The correct method is "disliked_by".
Ah, thank you for the clarification. What's the proper way to remove a vote, then?
Sorry "disliked_by" casts a negative vote.
"unliked_by" will remove the vote.
I will update the docs!
Sorry to bother you, but I also tried unliked_by and all it seems to do is return false :(
1.9.3-p194 :073 > c.liked_by h
(0.5ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = 1 AND "votes"."votable_type" = 'Concept' AND "votes"."voter_id" = 1 AND "votes"."voter_type" = 'Hero'
ActsAsVotable::Vote Load (0.4ms) SELECT "votes".* FROM "votes" WHERE "votes"."votable_id" = 1 AND "votes"."votable_type" = 'Concept' AND "votes"."voter_id" = 1 AND "votes"."voter_type" = 'Hero' LIMIT 1
(0.1ms) begin transaction
(0.1ms) commit transaction
(0.3ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = 1 AND "votes"."votable_type" = 'Concept'
(0.3ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = 1 AND "votes"."votable_type" = 'Concept' AND "votes"."vote_flag" = 't'
(0.3ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = 1 AND "votes"."votable_type" = 'Concept' AND "votes"."vote_flag" = 'f'
(0.1ms) begin transaction
(0.1ms) commit transaction
=> true
1.9.3-p194 :074 > c.votes.up.count
(0.5ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = 1 AND "votes"."votable_type" = 'Concept' AND "votes"."vote_flag" = 't'
=> 1
1.9.3-p194 :075 > c.unliked_by h
=> false
1.9.3-p194 :076 > c.votes.up.count
(0.5ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = 1 AND "votes"."votable_type" = 'Concept' AND "votes"."vote_flag" = 't'
=> 1
I know the guy that added this feature wrote a test for it. Let me checkout and run the tests to see whats going on.
Ok, again documentation is wrong. Need to pass keyword hash into unvote function
c.unliked_by :voter => h
That did it. Thank you for the swift reply!
Hey guys, I am trying this gem now and it seems to not be working. When I try "post.unliked_by user" after liking it, it just returns true and does not delete the vote. I tried "post.unliked_by voter: user" and it returns: NoMethodError: undefined method `id' for #Hash:0x007ffb1929d6e8
Hi,
I can't seem to get unvoting to work. I have a Concepts model, which acts_as_votable, and a Hero (User) model that acts_as_voter. I'm not sure if there's anything wrong with my models:
Hero Model
(acts_as_voter)
Concept Model
(acts_as_votable)
What I tried in rails console:
Am I just doing something wrong?