You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prefer symbol arguments over strings for ordering.
973
+
974
+
String columns without a table name can cause an "ambiguous column name" error when ordering by a column that exists in multiple tables joined in the same query.
975
+
976
+
[source,ruby]
977
+
----
978
+
# bad
979
+
User.order('created_at DESC')
980
+
981
+
# good
982
+
User.order(created_at: :desc)
983
+
----
984
+
970
985
=== `pluck`
971
986
972
987
Use https://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-pluck[pluck] to select a single value from multiple records.
0 commit comments