Class: Country

Inherits:
Vyapari::ApplicationRecord show all
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

Instance Method Details

#can_be_deleted?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


32
33
34
# File 'app/models/country.rb', line 32

def can_be_edited?
  true
end

#display_nameObject


Instance Methods




28
29
30
# File 'app/models/country.rb', line 28

def display_name
  self.name_was
end