just an update of technoweenie's us_states for rails 2.2
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 11 commits ahead of thincloud:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
README.md
Rakefile
VERSION
init.rb
us_states_select.gemspec

README.md

us-state-select-plugin

From http://svn.techno-weenie.net/projects/plugins/us_states/, updated to run under rails 2.2.

To select "priority" states that show up at the top of the list, call like so:

<%= us_state_select 'child', 'state', :priority => %w(TX CA) %> 

Changing Option/Value with :show

The default...

<%= us_state_select 'child', 'state'%> 

...will yield this:

<option value="AK">Alaska</option>

Or you can change it up...

<%= us_state_select 'child', 'state', :show => :full %> 

...and get this.

<option value="Alaska">Alaska</option>

Options are:

  • :full = Alaska
  • :full_abb = Alaska
  • :abbreviations = AK
  • :abb_full_abb = AK - Alaska

You can also pass a proc to show:

<%= us_state_select 'child', 'state', :show => Proc.new {|state| [state.first, state.first]} %> 

The array you are iterating over looks like this:

[["Alaska", "AK"], ["Alabama","AL"], ...]