Skip validation when this_action

How can I write a condition in a validation that will skip validation if
it comes from a certain action?

:if => don't_validate_when_this_action

Or how do you handle this, with validation, when you have an update form
that are for updating certain fields/columns?

The model has no idea what action has caused it to be validated.
Either call save(false) which skips all validations, or let the model
know (eg have an instance variable which indicates which validations
can be skipped)


Frederick Cheung wrote:

not sure what you mean there.


Frederick Cheung wrote:

still a bit confusing.

Do you mean save as if I use a in the update action?

Is this the right way to write it?

def update
@object = Object.find(id)

Not quite - update_attributes does the save for you, so this will save
twice (although the update_attributes might fail because of the
@object = Object.find(id)
@object.attributes = params[:object]

Should do the trick