When to use association extensions against named areas?

With a cursory glance, they seem to be just two different approaches to the same set of problems, except that the areas with names are tied to a chain, but the extension of connections is not.

Can someone explain further or provide an example that would be more suitable for expanding the association than the named scope?

+6
ruby ruby-on-rails activerecord
source share
2 answers

Association extensions are very useful for creating custom methods for creating, updating, etc. (not required for search).

Since you have access to proxy_owner, proxy_reflection, proxy_target, you have a good hook in relation.

Check out the "Association Extension" section in Rails docs:

http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

+11
source share

Yes, you're right, the main difference is that named_scope are chains. But basically they perform the same function, namely, that communication extensions are faster.

0
source share

All Articles