Vanishing error messages from model

In my model, validation errors work properly. The problem comes when I
try to add custom messages with self.errors.add. If I check with the
debugger, the messages are in self.errors. A self.save runs with no
problem. The problem comes when the controller takes over. It does a
Model.find at the start of update and POOF all the messages are
cleared. How can I display the messages and behave like the validation
messages do ?? BTW, I’m running 2.3.9

Thanks
Bob [email protected]

On 26 February 2012 21:25, Bob S. [email protected] wrote:

In my model, validation errors work properly. The problem comes when I
try to add custom messages with self.errors.add. If I check with the
debugger, the messages are in self.errors. A self.save runs with no
problem. The problem comes when the controller takes over. It does a
Model.find at the start of update and POOF all the messages are
cleared. How can I display the messages and behave like the validation
messages do ?? BTW, I’m running 2.3.9

Why are you doing another find? You must already have the model
instance that the errors are for in order to add the errors to it. If
you fetch a new record then the errors do not apply to that record.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs