I have a rails program where I need to skip one step of validation, but that’s it. Is there a way to set up a validation so I can send in a param with object.valid? that tells the object to skip one validation.
This is what I have so far:
Model:
validates :event_id, :presence => true, :unless => :skip_event_id
Controller:
if new_lot.valid(:skip_event_id => :true)?
.
.
.
end
This gives me a syntax error for the .valid. I was just wondering if there is a way to make this work. Thanks!
Note: I still want all of my other validation to continue
You need to set that variable before hand, it can’t be checked on valid. Likewise, when using a method with a question mark you need to put the question mark before the parentheses.
Model:
Controller: