Something that I believe would be useful to prevent overzealous "updates"
via touch would be to allow a lambda to be specified to determine if the
touch should occur or not.

class Client
  belongs_to :project, touch: -> {|rec| rec.name_changed?}
end

In this case, the project association is only "touched" if only the client
name changes.  This way if there's a lot of client data that has no value
to the project object and the project is only concerned with a change to
just one client attribute (for example) this would only trigger the touch
in that case.

Since an attribute can be specified for touch, then perhaps the option
should be called touch_if and the touch is always performed when the main
object is destroyed.

class Client
  belongs_to :project, touch: true, touch_if: -> {|rec| rec.name_changed?}
end

Thoughts?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to