Today I found myself in need of calling the 'touch' method on all instances 
of one model that are associated via a "has_many" relationship to another 
model's instance.  I know this is possible with the "belongs_to" 
relationship by passing the "touch: true" option, so I assumed this would 
be available on "has_many" as well, however it looks like my assumption is 
incorrect.

I found a thread from 2010 
<https://groups.google.com/forum/#!searchin/rubyonrails-core/has_many$20touch|sort:date/rubyonrails-core/xiHmKDIcLi0/S-3fyYj_CgAJ>
 
which proposes this exact feature, and it appears the consensus at the time 
was that the drawbacks to the proposal would be prohibitive, and that 
sufficient alternatives already exist (such as an "after_save" callback 
which calls "touch" instead).  I propose that this alternative suffers from 
the same issues, in addition to which it also suffers from being 
non-intuitive from an API standpoint.  In other words, there may be other 
developers like me who see that :belongs_to allows a touch option, and who 
therefore assume the reverse is also true.

In case things have changed since 2010, and in the interest of making the 
API for "has_many" and "belongs_to" less surprising and more uniform, would 
the current core maintainers be willing to re-open this discussion?  I'm 
happy to provide a proposal for discussion along with supporting rationale.

Thanks!

Richie

-- 
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 https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to