From 58557179f8b957f2e140e363c482082a37220ad1 Mon Sep 17 00:00:00 2001 From: Tom Kadwill Date: Tue, 12 Aug 2014 12:31:59 +0100 Subject: [ci skip] Added documentation for belongs_to scope parameter --- activerecord/lib/active_record/associations.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 1c5a737696..e73b855241 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1366,6 +1366,17 @@ module ActiveRecord # * Post#create_author! (similar to post.author = Author.new; post.author.save!; post.author) # 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 record or customize the generated query + # when you access the associated object. + # + # Scope examples: + # belongs_to :user, -> { where(id: 2) } + # belongs_to :user, -> { joins(:friends) } + # belongs_to :level, ->(level) { where("game_level > ?", level.current) } + # # === Options # # [:class_name] -- cgit v1.2.3