2014-04-03 20:47:09 +08:00
|
|
|
class NoUse < ActiveRecord::Base
|
|
|
|
# attr_accessible :title, :body
|
2014-04-06 16:34:23 +08:00
|
|
|
belongs_to :no_use, :polymorphic => true
|
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
validates_presence_of :user
|
|
|
|
validates_uniqueness_of :user_id, :scope => [:no_use_type, :no_use_id]
|
|
|
|
validate :validate_user
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def validate_user
|
|
|
|
errors.add :user_id, :invalid unless user.nil? || user.active?
|
|
|
|
end
|
2014-04-03 20:47:09 +08:00
|
|
|
end
|