Comments (8)
Thanks, thats a documentation bug. The correct method is "disliked_by".
from acts_as_votable.
Ah, thank you for the clarification. What's the proper way to remove a vote, then?
from acts_as_votable.
Sorry "disliked_by" casts a negative vote.
"unliked_by" will remove the vote.
I will update the docs!
from acts_as_votable.
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
from acts_as_votable.
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.
from acts_as_votable.
Ok, again documentation is wrong. Need to pass keyword hash into unvote function
c.unliked_by :voter => h
from acts_as_votable.
That did it. Thank you for the swift reply!
from acts_as_votable.
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
from acts_as_votable.
Related Issues (20)
- Using with UUID's as primary key HOT 1
- N+1 problem with my voters votes. HOT 7
- acts_as_votable issue HOT 5
- CHANGELOG HOT 2
- current_user.voted_for? @post returns false regardless of vote HOT 1
- acts_as_votable_options somehow became nil HOT 5
- How do I get vote weight for a previous vote HOT 1
- Migration Generator on Rails 6 HOT 9
- 0.12.0 => 0.12.1 version upgrade is a bit painful HOT 3
- Destroying voter does not update cached values in votable HOT 2
- undefined local variable or method `acts_as_votable' HOT 4
- Deprecation warning when returning within an ActiveRecord transaction in Rails 6.1
- Update CI matrix HOT 3
- acts_as_votable not compatible with Rails 6.1? HOT 1
- Add news attributes model Vote HOT 1
- Multiple different reactions? HOT 3
- cached_votes_total doesn't update during factory bot tests
- Conflict with active_admin_role gem
- Could not find table "votes"
- How to override the act_as_votable gem table votes in my applicatio
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acts_as_votable.