Files
danbooru/app/models/post_vote.rb
albert 23656e3fa9 * Continued work on improving post view templates
* Added statistics-based estimator for related tag calculator
* Fleshed out IpBan class based on changes to Danbooru 1.xx
2010-04-29 17:32:15 -04:00

17 lines
339 B
Ruby

class PostVote < ActiveRecord::Base
class Error < Exception ; end
attr_accessor :is_positive
validates_uniqueness_of :ip_addr, :scope => :post_id
after_save :update_post_score
belongs_to :post
def update_post_score
if is_positive
post.increment!(:score)
else
post.decrement!(:score)
end
end
end