Method: MLS::Slugger::ActiveRecordBaseSluggerExtension::ClassMethods#find

Defined in:
lib/mls.rb

#find(*ids) ⇒ Object



101
102
103
104
105
106
107
108
109
110
# File 'lib/mls.rb', line 101

def find(*ids)
  friendly = -> (id) { id.respond_to?(:to_i) && id.to_i.to_s != id.to_s }
  return super if ids.size > 1 || !ids.all? { |x| friendly.call(x) }
  
  if ids.first.include?("@")
    self.filter(email_addresses: {address: ids.first}).first
  else
    find_by_slug!(ids.first)
  end
end