Last active
August 29, 2015 14:13
-
-
Save lbramos/740a6b14898d983c0558 to your computer and use it in GitHub Desktop.
Validate fields depending on the another field value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#problem: validate field2 and field3 depending on value of field1 | |
validates :field1, presence: true | |
validates :field2, presence: true, :if => Proc.new {|o| o.field1 == "Yes" } | |
validates :field3, presence: true, :if => Proc.new {|p| p.field1 == "No" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment