Though as far as I know, there’s no way of doing update_attributes and
bypassing all validations.
Another possibility for you would be to put validation conditions into
your
model using :if =>
validates_presence_of :order_lines, :message => ‘missing one or more
products.’, :on => :save, :if => some_condition
HOWEVER, as far as I know, the models aren’t supposed to be tightly
linked to
the controllers and have a good degree of enforced separation between
them,
so if you were going to check for the presence of a session variable (or
something) in your model, I think you’ll be out of luck as that kind of
stuff
belongs in the controller.
There’s probably a way you could do it but I can’t think right now,
sorry!
Another choice is to create the base model without the validations and
then inherit from it to add the validations. In the normal case use
the properly validated model, but when necessary fall back to the base
model.
pth
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.