Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #16575 from tomkadwill/added_has_many_scope_docume…
Browse files Browse the repository at this point in the history
…ntation

[ci skip] Added documentation for has_many scope parameter
  • Loading branch information
Zachary Scott committed Aug 20, 2014
2 parents 2b7d67d + b64cfac commit 6ef0dd9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions activerecord/lib/active_record/associations.rb
Expand Up @@ -1133,6 +1133,17 @@ module ClassMethods
# * <tt>Firm#clients.create!</tt> (similar to <tt>c = Client.new("firm_id" => id); c.save!</tt>)
# The declaration can also include an +options+ hash to specialize the behavior of the association.
#
# === Scopes
#
# You can pass a second argument +scope+ as a callable (i.e. proc or
# lambda) to retrieve a specific set of records or customize the generated
# query when you access the associated collection.
#
# Scope examples:
# has_many :comments, -> { where(author_id: 1) }
# has_many :employees, -> { joins(:address) }
# has_many :posts, ->(post) { where("max_post_length > ?", post.length) }
#
# === Options
# [:class_name]
# Specify the class name of the association. Use it only if that name can't be inferred
Expand Down

0 comments on commit 6ef0dd9

Please sign in to comment.