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.

Touch does not propagate anymore

#5271

Since touch method has changed significantly, there no possibility to do something like this anymore:

class FirstModel < ActiveRecord::Base

end

class SecondModel < ActiveRecord::Base
  belongs_to :first_model, :touch => true
end

class ThirdModel < ActiveRecord::Base
  belongs_to :second_model, :touch => true
end

m = ThirdModel.first
m.touch # updates m record only, doesn't execute callbacks

m.attributes = { ... }
m.save! # updates m and m.second_model only

I think it was a really useful feature - I used it for caching or versioning several times. Is there any reason (apart from higher performance) to do it using update_attribute instead of saving the model?

Reported by Jakub Kuźma · August 2nd, 2010 @ 08:36 AM

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

Activity

  1. José Valim
    José Valim
    • Milestone cleared.
    • State changed from new to open
    • Assigned user set to José Valim
    • Importance changed from to Low

    August 2nd, 2010 @ 09:23 AM

  2. Jakub Kuźma
    Jakub Kuźma

    Added failing test.

    The code raises:
    SQLite3::SQLException: near "WHERE": syntax error: UPDATE "toys" SET WHERE ("toys"."toy_id" = 1)

    ... cause there's no timestamp in toys table. In my opinion the code should be correct, and change the timestamp in Owner record.

    August 2nd, 2010 @ 10:11 AM

  3. Jakub Kuźma
  4. Repository
  5. Jeremy Kemper