Skip to content

Commit 2cacf5c

Browse files
committed
Update has_one example to use descending order [ci skip]
Updated the `has_one :last_comment` example in the documentation to specify descending order ('posted_on desc'). This change ensures the ordering aligns with the name last_comment, making the example more intuitive and consistent with its intended purpose.
1 parent 38e9a72 commit 2cacf5c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activerecord/lib/active_record/associations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ def has_many(name, scope = nil, **options, &extension)
14851485
# has_one :credit_card, dependent: :destroy # destroys the associated credit card
14861486
# has_one :credit_card, dependent: :nullify # updates the associated records foreign
14871487
# # key value to NULL rather than destroying it
1488-
# has_one :last_comment, -> { order('posted_on') }, class_name: "Comment"
1488+
# has_one :last_comment, -> { order('posted_on desc') }, class_name: "Comment"
14891489
# has_one :project_manager, -> { where(role: 'project_manager') }, class_name: "Person"
14901490
# has_one :attachment, as: :attachable
14911491
# has_one :boss, -> { readonly }

0 commit comments

Comments
 (0)