gitastic
gitastic

Reputation: 526

Rails, country_select, save country name to model database

Need some help here...

I am using the country_select gem to pull the countries into a drop-down list in a form:

<%= f.label :country_code, "Country Traveled:" %>
<%= f.country_select :country_code, prompt: "Select a country" %>

The code above pulls the full country name (i.e., France, Germany, etc.) on my form, but it stores the country_code (FR, DE) in my model database.

How do I store the full country name in my model instead? Your reply GREATLY appreciated! Thanks in advance!

Upvotes: 1

Views: 1243

Answers (1)

Alireza
Alireza

Reputation: 2691

I have forked the original country_select gem and modified it to have country name as the value when sending the form the backend. You can fork, clone or point the gem in your gemfile to my repository :

gem 'country_select', git: 'https://github.com/alibabajan/country_select.git'

Upvotes: 3

Related Questions