|
| 1 | +# RailsCountrySelect |
| 2 | +This project is based on Rails 2 plugin created by LukeCarrier [rails-country-select](https://github.com/rderoldan1/rails-country-select/blob/master/lib/country_definitions.rb) |
| 3 | +Select tag in order to choose a country in your forms, provides 4 options. |
| 4 | +1. Country Name. |
| 5 | +2. Cod |
| 6 | +3. ISO cod 2 chars ('CO', 'AF', 'AX', 'AL') |
| 7 | +4. ISO cod 3 chars ('COL', 'AFG', 'ALA', ALB') |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +Add this line to your application's Gemfile: |
| 12 | + |
| 13 | + gem 'rails_country_select' |
| 14 | + |
| 15 | +And then execute: |
| 16 | + |
| 17 | + $ bundle |
| 18 | + |
| 19 | +Or install it yourself as: |
| 20 | + |
| 21 | + $ gem install rails_country_select |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +### Basic |
| 26 | +value : country cod number |
| 27 | +text : country name |
| 28 | +```ruby |
| 29 | +<%= form_for @user do |f| %> |
| 30 | + <%= f.country_select :country %> |
| 31 | +<% end %> |
| 32 | +``` |
| 33 | +
|
| 34 | +HTML generated |
| 35 | +```html |
| 36 | + <select id="cliente_nacionalidad" name="user[country]"> |
| 37 | + <option value="4">Afghanistan</option> |
| 38 | + <option value="248">Albania</option> |
| 39 | + <option value="8">Ã
land Islands</option> |
| 40 | + <option value="12">Algeria</option> |
| 41 | +`` |
| 42 | + |
| 43 | +### Advanced |
| 44 | +values, keys : [:names, :nums, :alpha2s, :alpha3s] |
| 45 | +selected : set default value |
| 46 | +prompt : message |
| 47 | +```ruby |
| 48 | +<%= form_for @user do |f| %> |
| 49 | + <%= f.country_select :country, {:keys => :names, :values => :alpha2s, :selected => "CO"}, :prompt => "Choose a country" |
| 50 | +<% end %> |
| 51 | +``` |
| 52 | + |
| 53 | +HTML generated |
| 54 | +```html |
| 55 | +<select id="cliente_nacionalidad" name="user[country]" prompt="Choose a country" value="CO"> |
| 56 | + <option value="AF">Afghanistan</option> |
| 57 | + <option value="AL">Albania</option> |
| 58 | + <option value="AX">Ã
land Islands</option> |
| 59 | + <option value="DZ">Algeria</option> |
| 60 | +`` |
| 61 | +## Contributing |
| 62 | +
|
| 63 | +1. Fork it |
| 64 | +2. Create your feature branch (`git checkout -b my-new-feature`) |
| 65 | +3. Commit your changes (`git commit -am 'Add some feature'`) |
| 66 | +4. Push to the branch (`git push origin my-new-feature`) |
| 67 | +5. Create new Pull Request |
0 commit comments