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.

Cloned object mimic changed_attributes from creator after being clonde

#4614

After creating a clone , when changing an attribute in either the parent or the clone, both objects are marked as changed.

Here's a failing test.

Reported by Federico Brubacher · May 16th, 2010 @ 11:29 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. pleax
    pleax

    Verified. Reproduces on master.

    May 16th, 2010 @ 12:05 PM

  2. José Valim
    José Valim
    • Milestone cleared.
    • Tag changed from 3.0, activerecord, dirty to 3.0, activerecord, bugmash, dirty

    May 16th, 2010 @ 02:10 PM

  3. Federico Brubacher
    Federico Brubacher
    • Tag changed from 3.0, activerecord, bugmash, dirty to 3.0, activerecord, dirty

    I've attached a patch.

    This patch includes the test case that no longer fails and a fix.

    May 16th, 2010 @ 02:35 PM

  4. Federico Brubacher
    Federico Brubacher
    • Tag changed from 3.0, activerecord, dirty to 3.0, activerecord, dirty, patch

    May 16th, 2010 @ 02:36 PM

  5. Federico Brubacher
    Federico Brubacher
    • Tag changed from 3.0, activerecord, dirty, patch to 3.0, activerecord, bugmash, dirty, patch

    May 16th, 2010 @ 02:37 PM

  6. Wijnand Wiersma
    Wijnand Wiersma

    +1 patch works fine, tests pass

    May 16th, 2010 @ 02:45 PM

  7. PacoGuzman
    PacoGuzman

    +1 patch applies clean, all test pass

    May 16th, 2010 @ 02:51 PM

  8. José Valim
    José Valim
    • Assigned user set to José Valim

    Federico, could you change your patch to make changed_attributes a public method, so we don't need to use instance_variable_get?

    May 16th, 2010 @ 03:11 PM

  9. Federico Brubacher
    Federico Brubacher

    Jose, here is the patch with marked attributes as public

    May 16th, 2010 @ 03:51 PM

  10. Santiago Pastorino
    Santiago Pastorino
    • Tag changed from 3.0, activerecord, bugmash, dirty, patch to 3.0, activerecord, bugmash, bugmash-review, dirty, patch
    • State changed from new to verified

    Great federico +1

    May 16th, 2010 @ 08:45 PM

  11. Rizwan Reza
    Rizwan Reza
    • Tag changed from 3.0, activerecord, bugmash, bugmash-review, dirty, patch to 3.0, activerecord, bugmash-review, dirty, patch

    May 16th, 2010 @ 09:39 PM

  12. PacoGuzman
  13. Repository
    Repository
    • State changed from verified to resolved

    May 16th, 2010 @ 10:09 PM

  14. Matt Jones
    Matt Jones

    Quick question: how does this interact with the issue from #2919 Activerecord::Base#clone does not set dirty bits?

    Also note that the use of dup to create the new changed_attributes means another place where dirty tracking combined with serialized attributes can go awry (see also #3474 _was doesn't work correctly for serialized fields with nested elements).

    May 16th, 2010 @ 10:14 PM

  15. Rizwan Reza
    Rizwan Reza
    • Tag changed from 3.0, activerecord, bugmash-review, dirty, patch to 3.0, activerecord, dirty, patch

    May 17th, 2010 @ 12:22 PM

  16. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM

  17. joson
    joson

    Very nice, thank you for you sharing. A Replica Breitling is a timepiece of high quality and functionality and you will have all the class, prestige and luxury of a wealthy, successful individual. By choosing from our selection of luxury Replica Watches , you can improve your self-esteem and feel confident to enter new circles of business associates and friends. These Rolex Replicas will surely enhance your style and only you will know the watch you wear did not cost you $1,000's of dollars.
    .

    April 29th, 2011 @ 09:07 AM