This project is archived and is in readonly mode.

#4460 ✓committed
Si

Validates_acceptance_of is not respecting database field

Reported by Si | April 22nd, 2010 @ 10:27 PM | in 3.0.2

In AcceptanceValidator#setup (/lib/active_model/validations/acceptance.rb), the class instance methods are inspected, to see if a writer method exists for each validated attribute. If not, an accessor for that attribute is created:

new_attributes = attributes.reject { |name| klass.instance_methods.map(&:to_s).include?("#{name}=") }                                                  
klass.send(:attr_accessor, *new_attributes)

However, klass.instance_methods does not pick up on my database backed fields. This leads to creating an overridden method that will not actually write the underlying attribute.

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

Attachments

Referenced by

Pages