From 57309c752e1caf56df67c404700e40afc78ac038 Mon Sep 17 00:00:00 2001 From: Orhan Toy Date: Sun, 22 Jul 2018 14:12:29 +0200 Subject: [ci skip] Use consistent hash syntax in AR docs The examples with `.where` uses hash w/ symbol keys so it would be more consistent to also do this with `.new`. Also from my experience the hash w/ symbol keys is more widely used with `where/new/create` etc. in ActiveRecord. --- activerecord/lib/active_record/associations.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 3b581d6fe8..1ee52945ea 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1232,9 +1232,9 @@ module ActiveRecord # * Firm#clients.size (similar to Client.count "firm_id = #{id}") # * Firm#clients.find (similar to Client.where(firm_id: id).find(id)) # * Firm#clients.exists?(name: 'ACME') (similar to Client.exists?(name: 'ACME', firm_id: firm.id)) - # * Firm#clients.build (similar to Client.new("firm_id" => id)) - # * Firm#clients.create (similar to c = Client.new("firm_id" => id); c.save; c) - # * Firm#clients.create! (similar to c = Client.new("firm_id" => id); c.save!) + # * Firm#clients.build (similar to Client.new(firm_id: id)) + # * Firm#clients.create (similar to c = Client.new(firm_id: id); c.save; c) + # * Firm#clients.create! (similar to c = Client.new(firm_id: id); c.save!) # * Firm#clients.reload # The declaration can also include an +options+ hash to specialize the behavior of the association. # @@ -1405,9 +1405,9 @@ module ActiveRecord # An Account class declares has_one :beneficiary, which will add: # * Account#beneficiary (similar to Beneficiary.where(account_id: id).first) # * Account#beneficiary=(beneficiary) (similar to beneficiary.account_id = account.id; beneficiary.save) - # * Account#build_beneficiary (similar to Beneficiary.new("account_id" => id)) - # * Account#create_beneficiary (similar to b = Beneficiary.new("account_id" => id); b.save; b) - # * Account#create_beneficiary! (similar to b = Beneficiary.new("account_id" => id); b.save!; b) + # * Account#build_beneficiary (similar to Beneficiary.new(account_id: id)) + # * Account#create_beneficiary (similar to b = Beneficiary.new(account_id: id); b.save; b) + # * Account#create_beneficiary! (similar to b = Beneficiary.new(account_id: id); b.save!; b) # * Account#reload_beneficiary # # === Scopes @@ -1746,8 +1746,8 @@ module ActiveRecord # * Developer#projects.size # * Developer#projects.find(id) # * Developer#projects.exists?(...) - # * Developer#projects.build (similar to Project.new("developer_id" => id)) - # * Developer#projects.create (similar to c = Project.new("developer_id" => id); c.save; c) + # * Developer#projects.build (similar to Project.new(developer_id: id)) + # * Developer#projects.create (similar to c = Project.new(developer_id: id); c.save; c) # * Developer#projects.reload # The declaration may include an +options+ hash to specialize the behavior of the association. # -- cgit v1.2.3