Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord::Error does not allow values to add errors

#3477

(Message from #3147 ActiveRecord::Error#full_message broken when used with I18n and autosave asso... by Chris Hapgood)

Briefly: an error on an attribute cannot be set as the result of an exception computing the value of the attribute.

For example:

def v compute_it rescue errors.add(:v, "Dadgummit") end

When compute_it raise an exception, ActiveRecord::Error#initialize references v, which in turn raises another exception, which adds another error, which in turn proves that my stack is not infinitely deep.

Is it reasonable to assume that ActiveRecord::Error instances can reference its erroneous attribute's value? If so, the above pattern won't work and instead a sentinel value will need to be set (U-G-L-Y).

Reported by José Valim · November 10th, 2009 @ 01:08 PM

State: resolved
Milestone: 2.3.6
Assigned to: josh josh
Importance: Low