On Fri, Apr 16, 2010 at 6:55 AM, Diego Carrion <[email protected]> wrote:
> Hi,
> it would be nice to have the touch option in has_many associations also.
> I have a scenario like this:
> An user has some credit (money) and some advertises. Each advertise can be
> enabled or disabled depending on some rules. One of the rules is that the
> user should have money. Each time the money of the user change, the
> advertises are touched, enabled/disabled and then cached, as they are much
> more requested that updated.

I'm a little concerned that adding :touch to has_many and friends is
encouraging bad practice (and terrible performance) when there's
almost certainly a more performant solution available.  It seems risky
to me to allow a single option on association to cause every instance
to be instantiated, changed, and written back to the database.

In your particular case couldn't your cache keys include the
updated_at value from a user?   Alternatively you can get the
behaviour you want with a 1 line after_save function without too much
hassle?

Is there a use-case I'm missing here?

-- 
Cheers

Koz

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to