lib/voting/models/voting/vote.rb in voting-0.3.0 vs lib/voting/models/voting/vote.rb in voting-0.4.0
- old
+ new
@@ -23,9 +23,10 @@
negative == 1 ? 'negative' : 'none'
end
def self.create(author:, resource:, scopeable: nil, value:)
+ value = value.to_i
record = find_or_initialize_by(author: author, resource: resource, scopeable: scopeable)
attribute = value.positive? ? :positive : :negative
canceled = record.persisted? && value.abs == record[attribute]
record.negative = 0