Class: Countrizable::ActiveRecord::CountryValue
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Countrizable::ActiveRecord::CountryValue
- Defined in:
- lib/countrizable/active_record/country_value.rb
Class Method Summary collapse
-
.table_exists? ⇒ Boolean
Sometimes ActiveRecord queries .table_exists? before the table name has even been set which results in catastrophic failure.
-
.valued_country_codes ⇒ Object
prev translated_locales.
Instance Method Summary collapse
Class Method Details
.table_exists? ⇒ Boolean
Sometimes ActiveRecord queries .table_exists? before the table name has even been set which results in catastrophic failure.
10 11 12 |
# File 'lib/countrizable/active_record/country_value.rb', line 10 def table_exists? table_name.present? && super end |
.valued_country_codes ⇒ Object
prev translated_locales
22 23 24 |
# 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 |
Instance Method Details
#country_code ⇒ Object
27 28 29 30 |
# 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) ⇒ Object
32 33 34 |
# File 'lib/countrizable/active_record/country_value.rb', line 32 def country_code=(country_code) write_attribute :country_code, country_code.to_s end |