Module: Railslove::Plugins::FindByParam::SingletonMethods

Defined in:
lib/find_by_param.rb

Instance Method Summary collapse

Instance Method Details

#find_by_param(value, args = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/find_by_param.rb', line 38

def find_by_param(value,args={})
  if permalink_options[:prepend_id]
    param = "id"
    value = value.to_i
  else
    param = permalink_options[:field]
  end
  self.send("find_by_#{param}".to_sym, value, args)
end

#find_by_param!(value, args = {}) ⇒ Object

Raises:

  • (::ActiveRecord::RecordNotFound)


48
49
50
51
52
53
# File 'lib/find_by_param.rb', line 48

def find_by_param!(value, args={})
  param = permalink_options[:field]
  obj = find_by_param(value, args)
  raise ::ActiveRecord::RecordNotFound unless obj
  obj
end