Feature Request- adding 'touch: true' option to :has_many relationship

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Feature Request- adding 'touch: true' option to :has_many relationship

Richie
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 href="https://groups.google.com/forum/#!searchin/rubyonrails-core/has_many$20touch|sort:date/rubyonrails-core/xiHmKDIcLi0/S-3fyYj_CgAJ">a thread from 2010 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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.