FriendlyId::FinderMethods

These methods will be added to the model's {FriendlyId::Base#relation_class relation_class}.

Protected Instance Methods

exists?(id = false) click to toggle source

FriendlyId overrides this method to make it possible to use friendly id's identically to numeric ids in finders.

@example

person = Person.exists?(123)
person = Person.exists?("joe")
person = Person.exists?({:name => 'joe'})
person = Person.exists?(['name = ?', 'joe'])

@see FriendlyId::ObjectUtils

# File lib/friendly_id/finder_methods.rb, line 30
def exists?(id = false)
  return super if id.unfriendly_id?
  super @klass.friendly_id_config.query_field => id
end
find_one(id) click to toggle source

FriendlyId overrides this method to make it possible to use friendly id's identically to numeric ids in finders.

@example

person = Person.find(123)
person = Person.find("joe")

@see FriendlyId::ObjectUtils

# File lib/friendly_id/finder_methods.rb, line 15
def find_one(id)
  return super if id.unfriendly_id?
  where(@klass.friendly_id_config.query_field => id).first or super
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.