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.

Move ActiveModel::AttributeMethods#attribute_methods_generated? to ActiveRecord

#6428

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).

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

State: resolved
Milestone: none
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. wildchild
    wildchild
    • Tag changed from active model, active record to active model, active record, patch

    February 20th, 2011 @ 04:10 PM

  2. José Valim
    José Valim
    • Importance changed from to Low

    I cannot apply it. Please rebase?

    March 1st, 2011 @ 06:23 PM

  3. wildchild
    wildchild

    Rebased. Applies on master smoothly.

    March 1st, 2011 @ 06:59 PM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [24faddd60c5fd148c8264898aeca2d5f36b25a4b]) Move ActiveModel::AttributeMethods#attribute_methods_generated? to ActiveRecord, so it's flexible now

    [#6428 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    https://github.com/rails/rails/commit/24faddd60c5fd148c8264898aeca2...

    March 1st, 2011 @ 07:32 PM