Giter Club home page Giter Club logo

Comments (8)

ryanto avatar ryanto commented on July 2, 2024

Thanks, thats a documentation bug. The correct method is "disliked_by".

from acts_as_votable.

 avatar commented on July 2, 2024

Ah, thank you for the clarification. What's the proper way to remove a vote, then?

from acts_as_votable.

ryanto avatar ryanto commented on July 2, 2024

Sorry "disliked_by" casts a negative vote.

"unliked_by" will remove the vote.

I will update the docs!

from acts_as_votable.

 avatar commented on July 2, 2024

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.

ryanto avatar ryanto commented on July 2, 2024

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.

ryanto avatar ryanto commented on July 2, 2024

Ok, again documentation is wrong. Need to pass keyword hash into unvote function

c.unliked_by :voter => h

from acts_as_votable.

 avatar commented on July 2, 2024

That did it. Thank you for the swift reply!

from acts_as_votable.

parruda avatar parruda commented on July 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.