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.

Marking Activerecord object as dirty

#4298

Hi all,

I just tried the following:

c = Content.find(1)
c.text => "foo"
c.text.sub!("bar")
c.save!

I think people would assume that the record gets saved to the database - but it doesn't.
Is this behavior correct?

Gerold

Reported by geroldboehler · March 30th, 2010 @ 12:31 PM

State: wontfix
Milestone: none
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Jerry Cheung
    Jerry Cheung

    ActiveRecord::Dirty keeps track of changes through the '=' operator for the attribute. You can use the attr_will_change! method to specify if a attribute will be modified in place. There's an example at: http://ryandaigle.com/articles/2008/3/31/what-s-new-in-edge-rails-d...

    March 30th, 2010 @ 01:42 PM

  2. Tanel Suurhans
    Tanel Suurhans

    I suppose it would be too costly do have some kind of a diff logic run before the call to save, to see if some attributes have changed?

    April 19th, 2010 @ 08:20 PM

  3. gnufied
    gnufied
    • Tag set to rails3 arel, invalid

    April 21st, 2010 @ 05:37 AM

  4. gnufied
    gnufied
    • Assigned user set to Pratik

    April 21st, 2010 @ 07:14 PM

  5. Ryan Bigg
    Ryan Bigg

    Do c.text = c.text.sub("bar") instead.

    April 25th, 2010 @ 12:25 AM

  6. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to wontfix

    April 25th, 2010 @ 12:47 AM