Module: HasHandleFallback::ClassMethods

Defined in:
lib/has_handle_fallback.rb

Instance Method Summary collapse

Instance Method Details

#find_by_id_or_handle(param) ⇒ Object Also known as: []



46
47
48
49
50
51
52
53
54
# File 'lib/has_handle_fallback.rb', line 46

def find_by_id_or_handle(param)
  return if param.blank?
  param = param.to_s
  if param =~ HasHandleFallback::RECORD_ID_REGEXP
    find_by_id param
  else
    first :conditions => [ "#{quoted_table_name}.`#{has_handle_fallback_options[:handle_column]}` LIKE ?", param ]
  end
end