Module: MuckEngine::Models::MuckCountry::ClassMethods
- Defined in:
- lib/muck-engine/models/country.rb
Instance Method Summary collapse
-
#build_state_prompts(country_id, any = false, refresh_ids = false) ⇒ Object
Note that the strings from here are also hard coded into application.js.
- #canada?(country, refresh_ids = false) ⇒ Boolean
- #uk_country?(country, refresh_ids = false) ⇒ Boolean
- #us ⇒ Object
Instance Method Details
#build_state_prompts(country_id, any = false, refresh_ids = false) ⇒ Object
Note that the strings from here are also hard coded into application.js
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/muck-engine/models/country.rb', line 32 def build_state_prompts(country_id, any = false, refresh_ids = false) if uk_country?(country_id, refresh_ids) label = 'Choose County' if any prompt = 'Any County (or unknown)' else prompt = 'Please select a county' end elsif canada?(country_id, refresh_ids) label = 'Choose Province' if any prompt = 'Any Province (or unknown)' else prompt = 'Please select a province' end else label = 'Choose State' if any prompt = 'Any State (or unknown)' else prompt = 'Please select a state' end end [label, prompt] end |
#canada?(country, refresh_ids = false) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/muck-engine/models/country.rb', line 25 def canada?(country, refresh_ids = false) @@canada_id = nil if refresh_ids @@canada_id ||= self.find_by_abbreviation('CA').id @@canada_id == get_country_id(country) end |
#uk_country?(country, refresh_ids = false) ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/muck-engine/models/country.rb', line 17 def uk_country?(country, refresh_ids = false) if refresh_ids || !defined?(@@uk_country_ids) uk_countries = self.find(:all, :conditions => ["abbreviation in (?)", ['ENG', 'IE', 'WAL', 'SCT']]) @@uk_country_ids = uk_countries.map(&:id) end @@uk_country_ids.include?(get_country_id(country)) end |
#us ⇒ Object
13 14 15 |
# File 'lib/muck-engine/models/country.rb', line 13 def us self.find_by_abbreviation('US') end |