Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4fabbfe1ff
Fetching contributors…

Cannot retrieve contributors at this time

53 lines (37 sloc) 1.538 kb


carmen-rails is a Rails 3 plugin that supplies two new form helper methods: country_select and subregion_select. It uses carmen as its source of geographic data.


Just add carmen-rails to your Gemfile:

gem 'carmen-rails', '~> 1.0.0.beta3'


<%= form_for(@order) do |f| %>
  <div class="field">
    <%= f.label :country_code %><br />
    <%= f.country_select :country_code, {priority: %w(US CA)}, prompt: 'Please select a country' %>
<% end %>

How do I only display a subset of countries/regions?

Carmen had a concept of excluded countries in the old days, where you could specify certain countries or regions to not include in a select.

The new (and much more flexible) way to handle this is to write a helper method that returns the subset of regions you want to provide:

def only_us_and_canada{|c| %w{US CA}.include?(c.code)}

And then in your form something like this:

<%= :country, region_options_for_select(only_us_and_canada) %>

More docs coming soon. In the meantime, all of the public methods in carmen-rails have been thoroughly TomDoc'ed.

Demo app

There is a live demo app that shows carmen-rails in action, and includes a step-by-step setup guide.

Jump to Line
Something went wrong with that request. Please try again.