module WhereLower::ActiveRecordExtension::ClassMethods
Public Instance Methods
where_lower(fields)
click to toggle source
A bit like `where`, but only accept hash, with value of `String`, `Array`, `Range`
@api
@param fields [Hash]
the conditions in hash, values will be downcase It could also be a 1 level deep hash so that it can be used in join
@example Find user by username case insensitively
User.where_lower(username: param[:name])
@example Find user by alias case insensitively
User.join(:aliases).where_lower(aliases:{name: param[:name]})
@raise [ArgumentError] when fields is not a Hash
# File lib/where_lower/active_record_extension.rb, line 28 def where_lower(fields) fail AugumentError, "fields is not a Hash" unless fields.is_a?(Hash) WhereLower::Base.spawn_lower_scope(self, fields) end