Class: Country

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/forge/app/models/country.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.options_for_selectObject



18
19
20
# File 'lib/forge/app/models/country.rb', line 18

def self.options_for_select
  Country.active.all.collect { |c| [c.title, c.id] }
end

Instance Method Details

#province_options_for_select(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/forge/app/models/country.rb', line 22

def province_options_for_select(options = {})
  display = options[:display] || "title"
  add_blank = options[:add_blank] || false
  text_for_blank = options[:text_for_blank] || "All"

  case display
  when "title"
    provinces = self.provinces.all.collect { |p| [p.title, p.id] }
  when "code"
    provinces = self.provinces.all.collect { |p| [p.code, p.id] }
  end

  if add_blank
    provinces.insert(0, [text_for_blank, 0])
  end

  provinces
end