No commit activity in last 3 years
No release in over 3 years
Better state selection Ruby on Rails plugin
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 1.2
 Project Readme

better-states-select

Originally from http://svn.techno-weenie.net/projects/plugins/us_states/ then was at https://github.com/thincloud/us-state-select-plugin.

No one seems to be maintaining this (ignoring my pull requests) so I've improved the library (added support for Canada) and now named it better-states-select.

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

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

Changing Option/Value with :show

The default...

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

...will yield this:

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

Or you can change it up...

<%= 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
  • :country - defaults to US states, but if you pass "Canada" you'll get Canadian provinces

You can also pass a proc to show:

<%= 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"], ...]