File tree Expand file tree Collapse file tree 1 file changed +2
-14
lines changed
activerecord/lib/active_record/relation Expand file tree Collapse file tree 1 file changed +2
-14
lines changed Original file line number Diff line number Diff line change @@ -111,23 +111,11 @@ def take!
111
111
# Find the first record (or first N records if a parameter is supplied).
112
112
# If no order is defined it will order by primary key.
113
113
#
114
- # Person.first # returns the first object fetched by SELECT * FROM people
114
+ # Person.first # returns the first object fetched by SELECT * FROM people ORDER BY people.id LIMIT 1
115
115
# Person.where(["user_name = ?", user_name]).first
116
116
# Person.where(["user_name = :u", { u: user_name }]).first
117
117
# Person.order("created_on DESC").offset(5).first
118
- # Person.first(3) # returns the first three objects fetched by SELECT * FROM people LIMIT 3
119
- #
120
- # ==== Rails 3
121
- #
122
- # Person.first # SELECT "people".* FROM "people" LIMIT 1
123
- #
124
- # NOTE: Rails 3 may not order this query by the primary key and the order
125
- # will depend on the database implementation. In order to ensure that behavior,
126
- # use <tt>User.order(:id).first</tt> instead.
127
- #
128
- # ==== Rails 4
129
- #
130
- # Person.first # SELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1
118
+ # Person.first(3) # returns the first three objects fetched by SELECT * FROM people ORDER BY people.id LIMIT 3
131
119
#
132
120
def first ( limit = nil )
133
121
if limit
You can’t perform that action at this time.
0 commit comments