Sha256: 7481c32e3bb5e812a2f6a93e72d9598c67089c356cec8a6298fb995c8f033986
Contents?: true
Size: 712 Bytes
Versions: 1
Compression:
Stored size: 712 Bytes
Contents
module Addresses class City < ActiveRecord::Base belongs_to :state has_many :neighborhoods class << self def filter(params = {}) return [] if params[:state_id].blank? && params[:name].blank? cities = City.order('name asc') cities = cities.where('state_id = ?', params[:state_id]) if params[:state_id] cities = cities.where("name #{query_word} ?", "%#{params[:name]}%") if params[:name] cities end private def query_word adapter == 'postgresql' ? 'ilike' : 'like' end def adapter ActiveRecord::Base.connection.instance_values["config"][:adapter] rescue nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
addresses-1.0.11 | app/models/addresses/city.rb |