Skip to content

Commit 57309c7

Browse files
committed
[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.
1 parent 20543c0 commit 57309c7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

activerecord/lib/active_record/associations.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,9 @@ module ClassMethods
12321232
# * <tt>Firm#clients.size</tt> (similar to <tt>Client.count "firm_id = #{id}"</tt>)
12331233
# * <tt>Firm#clients.find</tt> (similar to <tt>Client.where(firm_id: id).find(id)</tt>)
12341234
# * <tt>Firm#clients.exists?(name: 'ACME')</tt> (similar to <tt>Client.exists?(name: 'ACME', firm_id: firm.id)</tt>)
1235-
# * <tt>Firm#clients.build</tt> (similar to <tt>Client.new("firm_id" => id)</tt>)
1236-
# * <tt>Firm#clients.create</tt> (similar to <tt>c = Client.new("firm_id" => id); c.save; c</tt>)
1237-
# * <tt>Firm#clients.create!</tt> (similar to <tt>c = Client.new("firm_id" => id); c.save!</tt>)
1235+
# * <tt>Firm#clients.build</tt> (similar to <tt>Client.new(firm_id: id)</tt>)
1236+
# * <tt>Firm#clients.create</tt> (similar to <tt>c = Client.new(firm_id: id); c.save; c</tt>)
1237+
# * <tt>Firm#clients.create!</tt> (similar to <tt>c = Client.new(firm_id: id); c.save!</tt>)
12381238
# * <tt>Firm#clients.reload</tt>
12391239
# The declaration can also include an +options+ hash to specialize the behavior of the association.
12401240
#
@@ -1405,9 +1405,9 @@ def has_many(name, scope = nil, **options, &extension)
14051405
# An Account class declares <tt>has_one :beneficiary</tt>, which will add:
14061406
# * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.where(account_id: id).first</tt>)
14071407
# * <tt>Account#beneficiary=(beneficiary)</tt> (similar to <tt>beneficiary.account_id = account.id; beneficiary.save</tt>)
1408-
# * <tt>Account#build_beneficiary</tt> (similar to <tt>Beneficiary.new("account_id" => id)</tt>)
1409-
# * <tt>Account#create_beneficiary</tt> (similar to <tt>b = Beneficiary.new("account_id" => id); b.save; b</tt>)
1410-
# * <tt>Account#create_beneficiary!</tt> (similar to <tt>b = Beneficiary.new("account_id" => id); b.save!; b</tt>)
1408+
# * <tt>Account#build_beneficiary</tt> (similar to <tt>Beneficiary.new(account_id: id)</tt>)
1409+
# * <tt>Account#create_beneficiary</tt> (similar to <tt>b = Beneficiary.new(account_id: id); b.save; b</tt>)
1410+
# * <tt>Account#create_beneficiary!</tt> (similar to <tt>b = Beneficiary.new(account_id: id); b.save!; b</tt>)
14111411
# * <tt>Account#reload_beneficiary</tt>
14121412
#
14131413
# === Scopes
@@ -1746,8 +1746,8 @@ def belongs_to(name, scope = nil, **options)
17461746
# * <tt>Developer#projects.size</tt>
17471747
# * <tt>Developer#projects.find(id)</tt>
17481748
# * <tt>Developer#projects.exists?(...)</tt>
1749-
# * <tt>Developer#projects.build</tt> (similar to <tt>Project.new("developer_id" => id)</tt>)
1750-
# * <tt>Developer#projects.create</tt> (similar to <tt>c = Project.new("developer_id" => id); c.save; c</tt>)
1749+
# * <tt>Developer#projects.build</tt> (similar to <tt>Project.new(developer_id: id)</tt>)
1750+
# * <tt>Developer#projects.create</tt> (similar to <tt>c = Project.new(developer_id: id); c.save; c</tt>)
17511751
# * <tt>Developer#projects.reload</tt>
17521752
# The declaration may include an +options+ hash to specialize the behavior of the association.
17531753
#

0 commit comments

Comments
 (0)