This project is archived and is in readonly mode.

#5927 ✓committed
David Chelimsky

ActiveRecord should favor ActiveModel API

Reported by David Chelimsky | November 7th, 2010 @ 02:20 PM

ActiveModel introduced the persisted? method (inverse of new_record?), but ActiveRecord still uses new_record? internally and across associations. This means that extension libraries sometimes have to be aware of whether they're dealing with ActiveRecord or not.

Fixed in https://github.com/dchelimsky/rails/commit/e84cd8a2533c9581d76eca55...

NOTES:

  • patched against master as of c43d909ee28484c5e7d7d84b1228e10212d20737
  • there was one failing test before this commit, which is still failing:

    test/cases/associations/cascaded_eager_loading_test.rb:128
    test_eager_association_loading_with_has_many_sti_and_subclasses

  • there is one new failing test, but I question its validity. It specifies that to_key should return a non-nil value after destroy is called on a model. This seems like the opposite of what we would want, and this is the only new test failure (so no other code seems to rely on this behavior).

    test/cases/primary_keys_test.rb
    test_to_key_with_primary_key_after_destroy

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>

Referenced by

Pages