bigdir/app/models/apply_project_master.rb

17 lines
422 B
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class ApplyProjectMaster < ActiveRecord::Base
# attr_accessible :title, :body
# status 1是申请者2是版主
belongs_to :apply, :polymorphic => true
belongs_to :user
validates_presence_of :user
validates_uniqueness_of :user_id, :scope => [:apply_type, :apply_id]
validate :validate_user
protected
def validate_user
errors.add :user_id, :invalid unless user.nil? || user.active?
end
end