This project is archived and is in readonly mode.

#6428 ✓resolved
wildchild

Move ActiveModel::AttributeMethods#attribute_methods_generated? to ActiveRecord

Reported by wildchild | February 13th, 2011 @ 05:47 PM

In order to add ActiveModel::Dirty to models, people should use AttributeMethods. Everything is cool with AR-like models, but consider model like this:

  class Article < Model
    property :title
    property :body
    property :published_at, Time
  end

Currently we should use AttributeMethods#define_attribute_methods([:title, :body, :published_at]). In this DataMapper-like model it's impossible to determine all properties or find a nice workaround. Also, we can't call #define_attribute_methods multiple times, because it does nothing if #attribute_methods_generated? is positive.

My patch moves all this #attribute_methods_generated? tracking to ActiveRecord. Also #define_attribute_method added. All AR tests passes, Am test modified. Yeah, there is no backward compatibility, but it's pretty simple to override AM behavior just like it done for AR (see patch for details).

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>

Attachments