* Missing files
* Work on post exploration code by traversing dates
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
class PostVote < ActiveRecord::Base
|
||||
class Error < Exception ; end
|
||||
|
||||
attr_accessor :is_positive
|
||||
belongs_to :post
|
||||
before_validation :initialize_user, :on => :create
|
||||
validates_presence_of :post_id, :user_id, :score
|
||||
validates_inclusion_of :score, :in => [1, -1]
|
||||
|
||||
def score=(x)
|
||||
if x == "up"
|
||||
write_attribute(:score, 1)
|
||||
elsif x == "down"
|
||||
write_attribute(:score, -1)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize_user
|
||||
self.user_id = CurrentUser.user.id
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user