Rails 3.2 Validation - Multiple Fields
I have an award model. The NOMINATOR selects himself from a dropdown list, then selects the NOMINEE from another dropdown list.
How can I disallow self-nomination via a validation in the model? In other words, the nominator cannot select himself from the nominee selection list.
class Award < ActiveRecord::Base
belongs_to :nominator, :class_name => 'Employee', :foreign_key => 'nominator_id'
belongs_to :nominee, :class_name => 'Employee', :foreign_key => 'nominee_id'
validates :nominator_id, :nominee_id, :award_description, :presence => true
end
Thanks in advance!
I have an award model. The NOMINATOR selects himself from a dropdown list, then selects the NOMINEE from another dropdown list.
How can I disallow self-nomination via a validation in the model? In other words, the nominator cannot select himself from the nominee selection list.
class Award < ActiveRecord::Base
belongs_to :nominator, :class_name => 'Employee', :foreign_key => 'nominator_id'
belongs_to :nominee, :class_name => 'Employee', :foreign_key => 'nominee_id'
validates :nominator_id, :nominee_id, :award_description, :presence => true
end
Thanks in advance!
No comments:
Post a Comment