instance method
only
Ruby on Rails 8.0.4
Since v3.0.20Signature
only(*onlies)
Keeps only the condition(s) specified in onlies in the query, removing all others.
Post.order('id asc').only(:where) # keeps only the where condition, removes the order Post.order('id asc').only(:where, :order) # keeps only the where and order conditions
Parameters
-
onliesrest
Source
# File activerecord/lib/active_record/relation/spawn_methods.rb, line 67
def only(*onlies)
relation_with values.slice(*onlies)
end
Defined in activerecord/lib/active_record/relation/spawn_methods.rb line 67
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::SpawnMethods