diff options
author | Tom Kadwill <tomkadwill@gmail.com> | 2014-08-26 07:49:37 +0100 |
---|---|---|
committer | Tom Kadwill <tomkadwill@gmail.com> | 2014-08-26 07:49:37 +0100 |
commit | 64d3b5edd11f5d96d4ac3393247d04c9e225878f (patch) | |
tree | a3508054677c0e3f7bad7867d3813f39b1b61e67 /activerecord | |
parent | 99a5333c9d77db816906dabd5ce7f0cb44197bc3 (diff) | |
download | rails-64d3b5edd11f5d96d4ac3393247d04c9e225878f.tar.gz rails-64d3b5edd11f5d96d4ac3393247d04c9e225878f.tar.bz2 rails-64d3b5edd11f5d96d4ac3393247d04c9e225878f.zip |
[ci skip] Added documentation for has_and_belongs_to_many extension parameter
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 15 |
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] |