aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorZachary Scott <e@zzak.io>2014-08-26 00:02:32 -0700
committerZachary Scott <e@zzak.io>2014-08-26 00:02:32 -0700
commit49b27dba286b0f9536f1f0e366a431b762bf7885 (patch)
treea3508054677c0e3f7bad7867d3813f39b1b61e67 /activerecord/lib
parent99a5333c9d77db816906dabd5ce7f0cb44197bc3 (diff)
parent64d3b5edd11f5d96d4ac3393247d04c9e225878f (diff)
downloadrails-49b27dba286b0f9536f1f0e366a431b762bf7885.tar.gz
rails-49b27dba286b0f9536f1f0e366a431b762bf7885.tar.bz2
rails-49b27dba286b0f9536f1f0e366a431b762bf7885.zip
Merge pull request #16697 from tomkadwill/has_and_belongs_to_many_documenting_extension_param
[ci skip] Added documentation for has_and_belongs_to_many extension parameter
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 18d4291599..18da28d480 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1604,6 +1604,21 @@ module ActiveRecord
# where("default_category = ?", category.name)
# }
#
+ # === Extensions
+ #
+ # The +extension+ argument allows you to pass a block into a
+ # has_and_belongs_to_many association. This is useful for adding new
+ # finders, creators and other factory-type methods to be used as part of
+ # the association.
+ #
+ # Extension examples:
+ # has_and_belongs_to_many :contractors do
+ # def find_or_create_by_name(name)
+ # first_name, last_name = name.split(" ", 2)
+ # find_or_create_by(first_name: first_name, last_name: last_name)
+ # end
+ # end
+ #
# === Options
#
# [:class_name]