This project is archived and is in readonly mode.

#5646 new
Jamie

validates_associated throws 'can't modify frozen object' error

Reported by Jamie | September 17th, 2010 @ 05:35 AM

Steps to reproduce:
Create a value object using composed_of like in the Rails documentation. Use the :converter option to recreate the value object from the params hash when attributes= is called on the parent. Add validations to the value object. * Run those validations by using validates_associated in the entity where you have composed_of.

What happens:
* A 'can't modify frozen object' error is thrown.

Why it happens:
* Not really sure, but I tracked it as far as the valid? method in ActiveRecord::Validations. It appears to break in the "ensure" part of the that method. This was added in commit 82485068f8b64a49cbb6. When I overrode valid? in my value object, using the logic as it was before that commit, validates_associated started working as expected.

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages