Is it possible top validate the presence of 2 field?
Maybe I am blind, but I can’t figure out how to validate based on the
presence of 2 fields.
–
Lon B.
http://www.speedymac.com
AIM: spdemac
Is it possible top validate the presence of 2 field?
Maybe I am blind, but I can’t figure out how to validate based on the
presence of 2 fields.
–
Lon B.
http://www.speedymac.com
AIM: spdemac
Just do validates_presence_of on each? I suspect that that’s not what
you wanted to hear, and that I didn’t understand your problem, so to
roll your own validation, you can use validates_each. Example:
validates_each(:field1, :field2) do |record, field_name, field_value|
#This block is run once for each field, so 2x in this example.
record.errors.add “is invalid” if some_test.fails?
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs