Class: Nation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Nation
- Includes:
- ActionView::Helpers::AutoTagHelper::FormInfo, ActiveRecord::Mlang
- Defined in:
- app/models/nation.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.[](code_or_num) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/models/nation.rb', line 25 def self.[](code_or_num) col = :code_alpha2 if code_or_num.kind_of?(Numeric) col = :code_numeric else col = :code_alpha3 if code_or_num.to_s.strip.size == 3 end self.find_by(col => code_or_num) end |
Instance Method Details
#__display__ ⇒ Object
18 19 20 |
# File 'app/models/nation.rb', line 18 def __display__ self.name end |
#add_currency(code) ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/models/nation.rb', line 35 def add_currency(code) if cid = Currency[code].try(:id) CurrencyNationMap.find_or_create_by(nation_id: self.id, currency_id: cid) else nil end end |
#code2 ⇒ Object
22 |
# File 'app/models/nation.rb', line 22 def code2 ; self.code_alpha2 ; end |
#code3 ⇒ Object
23 |
# File 'app/models/nation.rb', line 23 def code3 ; self.code_alpha3 ; end |