Countries Regions And Cities By Peter Consuegra

An agile way to implement Countries, Regions and Cities in your project, without the need to create additional tables

Installation

Add this line to your application's Gemfile:

gem 'countries_regions_and_cities_by_peterconsuegra'

And then execute:

$ bundle install

Run the rake command to generate the necessary files:

$ bundle exec rake 'install_countries_regions_and_cities_to_model[your_model_name]'

Rails

Add this code to the _form.html.erb partial of your_model_name form


<div class="field" id="country_field">
<%= render partial: 'shared/peterconsuegra_country_select', locals: {model: form.object.class.name.downcase, label: "Country", selected: form.object.country} %>
</div>

<div class="field" id="region_field">
<%= render partial: 'shared/peterconsuegra_region_select', locals: {model: form.object.class.name.downcase, label: "Region / State", selected_country: form.object.country, selected: form.object.region} %>
</div>

<div class="field" id="city_field">
<%= render partial: 'shared/peterconsuegra_city_select', locals: {model: form.object.class.name.downcase, label: "City", selected_region: form.object.region, selected_country: form.object.country, selected: form.object.city} %>
</div>


Video Tutorial

Watch this video to see how it works

IMAGE ALT TEXT HERE

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/peterconsuegra/countries_regions_and_cities. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the CountriesRegionsAndCitiesByPeterconsuegra project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.