A question about representing a string from a model.
I have a Country model which has a list of countries.
The countries are in long form eg. United States, United Kingdom, etc.
I want to represent this data in short name form eg. USA, UK.
I don’t really want to change the names on the table column because on my forms I would like keep the long form names.
I thought I would add code in the model Country.rb if self.id == 123 “USA” but I’m sure this isn’t the right way.
Any help will be grand.
Much appreciated.
WD
It is better to store short names in additional field, see below links: