Posts

Showing posts with the label select country

I18n Country & City Select Fields - Reconstructing Carmen-Rails from Scratch

Image
One would think that Country/City selection fields are something so common that someone must have created a simple method to implement it. That may true to a point, but it turns out the City-State gem only provides English names, while the Carmen-Rails gem   - despite having I18n support - due to its dependence on the Carmen gem(https://github.com/carmen-ruby/carmen) - is no longer actively maintained. So, there's a few ways to get a working I18n Country/City select field working. The simplest might be to unpack the Carmen-Rails gem, change it to support Rails 5 with this fix , then install it by telling the Gemfile to install from local file. I did that initially,  but that didn't feel exactly right. So, I decided to reinvent the wheel and write the code from scratch. Now there are other gems that return country/subregions information with I18n support, such as the Countries gem and the Cities gem . However, for the purpose of making select fields, I found these gems ret...