class Countrizable::ActiveRecord::CountryValue

Public Class Methods

table_exists?() click to toggle source

Sometimes ActiveRecord queries .table_exists? before the table name has even been set which results in catastrophic failure.

Calls superclass method
# File lib/countrizable/active_record/country_value.rb, line 10
def table_exists?
  table_name.present? && super
end
valued_country_codes() click to toggle source
# File lib/countrizable/active_record/country_value.rb, line 22
def valued_country_codes #prev translated_locales
  select('DISTINCT country_code').order(:country_code).map(&:country_code)
end
with_country_codes(*country_codes) click to toggle source
# File lib/countrizable/active_record/country_value.rb, line 14
def with_country_codes(*country_codes)
  # Avoid using "IN" with SQL queries when only using one locale.
  country_codes = country_codes.flatten.map(&:to_s)
  country_codes = country_codes.first if country_codes.one?
  where :country_code => country_codes
end
Also aliased as: with_country_codes

Public Instance Methods

country_code() click to toggle source
# File lib/countrizable/active_record/country_value.rb, line 27
def country_code
  _country_code = read_attribute :country_code
  _country_code.present? ? _country_code.to_sym : _country_code
end
country_code=(country_code) click to toggle source
# File lib/countrizable/active_record/country_value.rb, line 32
def country_code=(country_code)
  write_attribute :country_code, country_code.to_s
end