19 lines
510 B
Ruby
19 lines
510 B
Ruby
class PoolVersion < ActiveRecord::Base
|
|
class Error < Exception ; end
|
|
|
|
validates_presence_of :updater_id, :updater_ip_addr
|
|
belongs_to :pool
|
|
belongs_to :updater, :class_name => "User"
|
|
before_validation :initialize_updater
|
|
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
|
|
|
|
def initialize_updater
|
|
self.updater_id = CurrentUser.id
|
|
self.updater_ip_addr = CurrentUser.ip_addr
|
|
end
|
|
|
|
def post_id_array
|
|
@post_id_array ||= post_ids.scan(/\d+/).map(&:to_i)
|
|
end
|
|
end
|