instance method
only
Ruby on Rails 3.1.12
Since v3.0.20Signature
only(*onlies)
Removes any condition from the query other than the one(s) specified in onlies.
Example:
Post.order('id asc').only(:where) # discards the order condition Post.order('id asc').only(:where, :order) # uses the specified order
Parameters
-
onliesrest
Source
# File activerecord/lib/active_record/relation/spawn_methods.rb, line 98
def only(*onlies)
result = self.class.new(@klass, table)
result.default_scoped = default_scoped
((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) & onlies).each do |method|
result.send(:"#{method}_values=", send(:"#{method}_values"))
end
(Relation::SINGLE_VALUE_METHODS & onlies).each do |method|
result.send(:"#{method}_value=", send(:"#{method}_value"))
end
# Apply scope extension modules
result.send(:apply_modules, extensions)
result
end
Defined in activerecord/lib/active_record/relation/spawn_methods.rb line 98
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::SpawnMethods