* Added statistics-based estimator for related tag calculator * Fleshed out IpBan class based on changes to Danbooru 1.xx
17 lines
339 B
Ruby
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
|