Sem descrição

saberma 98c9ee159b Update README.md há 11 anos atrás
app 4bdbc4a691 make dummy project compatiable with rails3.1 and 3.2 há 11 anos atrás
bin 21230b97bd init. há 11 anos atrás
config cd9363d89b show select. há 11 anos atrás
db 8cc5a049e2 config rspec. há 11 anos atrás
gemfiles 64dd58f355 update version v0.0.4 há 11 anos atrás
lib 64dd58f355 update version v0.0.4 há 11 anos atrás
spec 3ed7d35954 Gemfile.lock use rails3.1 as default. há 11 anos atrás
.gitignore 21230b97bd init. há 11 anos atrás
.rspec 8cc5a049e2 config rspec. há 11 anos atrás
.travis.yml 6832f25df0 use j6. há 11 anos atrás
Appraisals 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 há 11 anos atrás
Gemfile 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 há 11 anos atrás
Gemfile.lock 64dd58f355 update version v0.0.4 há 11 anos atrás
MIT-LICENSE 8e4256923e add MIT licentse to gemspec. há 11 anos atrás
README.md 98c9ee159b Update README.md há 11 anos atrás
Rakefile b399f86669 add appraisals gem. há 11 anos atrás
china_city.gemspec 9e7898be25 add appraisals config: support rails3.1, 3.2, and 4.0 há 11 anos atrás

README.md

ChinaCity 省市区级联选择

Build Status

china_city

支持 Rails3.1, Rails3.2, Rails4.0。

请留意,Rails3.1 与 Ruby2.0 不兼容,sprockets 无法正常解析 application.js,请使用 Ruby1.9。

简介

这是一个基于 Rails Engine 开发的插件,为 Rails 项目增加省市区三级(或者省市 二级)选择框,可用于实现收货地址等信息的录入。

安装

Gemfile

gem 'china_city'

app/assets/javascripts/application.js

//= require 'jquery'
//= require 'china_city/jquery.china_city'

config/routes.rb

mount ChinaCity::Engine => '/china_city'

使用

在页面中加入选择框,示例代码使用 slim 格式

  .city-group
    select.city-select
      option --省份--
      = options_for_select(ChinaCity.list)
    select.city-select
      option --城市--
    select.city-select
      option --地区--

请留意:所有选择框都要有 city-select class,并都包含于 class='city-group' 的 DOM 元素之下。

选择后的值为国家地区编码,如深圳市的为 440300,可通过调用 ChinaCity.get('440300') 将编码转化为城市名称。

贡献

git clone git@github.com:saberma/china_city.git
cd china_city
rake appraisal:install
cd spec/dummy
rails server # http://localhost:3000/china_city

测试

rvm use 2.0.0
rake appraisal:rails4 spec
rake appraisal:rails32 spec
rvm use 1.9.3
bundle install
rake appraisal:rails31 spec

类似项目