Class: Country
- Inherits:
-
Vyapari::ApplicationRecord
- Object
- ActiveRecord::Base
- Vyapari::ApplicationRecord
- Country
- Defined in:
- app/models/country.rb
Constant Summary collapse
- DELETE_MESSAGE =
"Cannot delete the country. You should first remove all the cities and exchange rates associated with this country."
Instance Method Summary collapse
- #can_be_deleted? ⇒ Boolean
- #can_be_edited? ⇒ Boolean
-
#display_name ⇒ Object
—————— Instance Methods ——————.
Instance Method Details
#can_be_deleted? ⇒ Boolean
36 37 38 39 40 41 42 43 |
# File 'app/models/country.rb', line 36 def can_be_deleted? if self.regions.any? || self.exchange_rates.any? self.errors.add(:base, DELETE_MESSAGE) return false else return true end end |
#can_be_edited? ⇒ Boolean
32 33 34 |
# File 'app/models/country.rb', line 32 def can_be_edited? true end |
#display_name ⇒ Object
Instance Methods
28 29 30 |
# File 'app/models/country.rb', line 28 def display_name self.name_was end |