module Mongoid::Criterion::Optional
Public Instance Methods
for_ids(*ids)
click to toggle source
# File lib/slugoid/mongoid/criterion/optional.rb, line 15 def for_ids(*ids) ids.flatten! if @klass.respond_to?(:acts_as_slugoid_options) && !ids.first.is_a?(BSON::ObjectId) if ids.size > 1 self.in( @klass.acts_as_slugoid_options[:store_as] => ::BSON::ObjectId.cast!(@klass, ids, @klass.primary_key.nil?) ) else @selector[@klass.acts_as_slugoid_options[:store_as]] = ids.first end self else for_ids!(*ids) end end
Also aliased as: for_ids!
for_ids!(*ids)
Overwrite the id method to find objects by the specified slug rather than the id. If you want to find via id you'll have to use An explicit finder like:
where(:_id => some_id)
Alias for: for_ids