CityHelper是一个提供国家,省,市选择框的小插件,这次更新增加了国家和国际化支持,目前只支持简体中文和英语。 安装 $ script/plugin install git://github.com/yzhang/city_helper.git 这会在你的config/locales目录下安装一个cities目录,这个目录包含了i18n的信息,还会在config/initializers目录增加一个city_helper.rb来设置i18n的加载目录。 使用 country_select(:user, :country, { :only => [:china], # 指定要显示的国家 :update => ‘state_select_id’, # 指定国家改变后要更新的省份选择框的id }, html_options) state_select(:user, :state, { :country => :china, # 指定默认显示那个国家的省份 :countries => [:china], # 只有在country_select中设置了update属性时才需设置这个属性 # 这个属性应该与country_select中的:only属性保持一致 :update => ‘city_select_id’, # 指定省份变动时要更新的城市选择框ID }, html_options) city_select(:user, :city, { [...]
