Plugin: state_select, generate drop down selection box for states
I have wrote my first plugin(state_select). This plugin allows to create drop down list for states, same as country_select method in rails. I know this is not a big deal…
UPDATE: Curently it can generate state list for India, US, Canada, Australia, Spain and Uganda(default is US).
Usage:
Return select and option tags for the given object and method, using state_options_for_select to generate the list of option tags.
Returns a string of option tags for states in a country. Supply a state name as selected to have it marked as the selected option tag.
NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
The svn repository can be found at http://opensvn.csie.org/state_select/trunk/
Install plugin by














Here is a patch to add Australian states:
Index: lib/state_select.rb
===================================================================
— lib/state_select.rb (revision 1)
+++ lib/state_select.rb (working copy)
@@ -23,6 +23,7 @@
US_STATES=[”Alaska”, “Alabama”, “Arkansas”, “Arizona”, “California”, “Colorado”, “Connecticut”, “Washington D.C.”, “Delaware”, “Florida”, “Georgia”, “Hawaii”, “Iowa”, “Idaho”, “Illinois”, “Indiana”, “Kansas”, “Kentucky”, “Louisiana”, “Massachusetts”, “Maryland”, “Maine”, “Michigan”, “Minnesota”, “Missourri”, “Mississippi”, “Montana”, “North Carolina”, “North Dakota”, “Nebraska”, “New Hampshire”, “New Jersey”, “New Mexico”, “Nevada”, “New York”, “Ohio”, “Oklahoma”, “Oregon”, “Pennsylvania”, “Puerto Rico”, “Rhode Island”, “South Carolina”, “South Dakota”, “Tennessee”, “Texas”, “Utah”, “Virginia”, “Vermont”, “Washington”, “Wisconsin”, “West Virginia”, “Wyoming”] unless const_defined?(”US_STATES”)
INDIA_STATES=[”Andhra Pradesh”, “Arunachal Pradesh”, “Assam”, “Bihar”, “Chhattisgarh”, “New Delhi”, “Goa”, “Gujarat”, “Haryana”, “Himachal Pradesh”, “Jammu and Kashmir”, “Jharkhand”, “Karnataka”, “Kerala”, “Madhya Pradesh”, “Maharashtra”, “Manipur”, “Meghalaya”, “Mizoram”, “Nagaland”, “Orissa”"Punjab”, “Rajasthan”, “Sikkim”, “Tamil Nadu”, “Tripura”, “Uttaranchal”, “Uttar Pradesh”, “West Bengal”] unless const_defined?(”INDIA_STATES”)
CANADA_STATES=[”Alberta”, “British Columbia”, “District of Columbia”, “Manitoba”, “New Brunswick”, “Newfoundland and Labrador”, “Northwest Territories”, “Nova Scotia”, “Nunavut”, “Prince Edward Island”, “Saskatchewan”, “Ontario”, “Quebec”] unless const_defined?(”CANADA_STATES”)
+ AUSTRALIA_STATES=[”Australian Capital Territory”, “New South Wales”, “Northern Territory”, “Queensland”, “South Australia”, “Tasmania”, “Victoria”, “Western Australia”] unless const_defined?(”AUSTRALIA_STATES”)
end
class ActionView::Helpers::InstanceTag
Index: README
===================================================================
— README (revision 1)
+++ README (working copy)
@@ -6,7 +6,7 @@
Usage:
state_select(object, method, country=’INDIA’, options = {}, html_options = {})
- Currently it supports only India, US and Canada
+ Currently it supports only India, US, Canada and Australia
If you want to add other country plese send me the list of states and I will add them.