Sha256: 83a627b4092926ea5aadfbcc3851c55f6cb7d4e45680668b8d89cb4fd94e7ce8
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module FriendlyId # These methods will be added to the model's {FriendlyId::Base#relation_class relation_class}. module FinderMethods protected # 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 def find_one(id) return super if id.unfriendly_id? where(@klass.friendly_id_config.query_field => id).first or super end # 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 def exists?(id = nil) return super if id.unfriendly_id? super @klass.friendly_id_config.query_field => id end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
friendly_id-4.0.0.beta13 | lib/friendly_id/finder_methods.rb |
friendly_id-4.0.0.beta12 | lib/friendly_id/finder_methods.rb |