This project is archived and is in readonly mode.

#3477 ✓resolved
José Valim

ActiveRecord::Error does not allow values to add errors

Reported by José Valim | November 10th, 2009 @ 01:08 PM | in 2.3.6

(Message from #3147 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).

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket


Referenced by