新手问题 有人知道 china_city 这个 gem 的 form_for 用法吗?

frank · October 23, 2013 · Last by rebecca9201 replied at March 07, 2017 · 2877 hits

有人知道这个 gem 的 form_for 用法吗?https://github.com/saberma/china_city 上面有 slim 的例子。我自己试了一下 form_for,但是没成功。

#1 楼 @iBachue 已经直接他了。想看看坛子里有没有其他人用过

我用的 simple_form,可 work

<%= simple_form_for [:account,@user] do |f| %>
 <div class="city-group">
    <%= f.select :province,  ChinaCity.list.unshift(["--省份--", 0]), {}, class: "city-select"%>
    <%= f.select :city, ChinaCity.list(f.object.province).presence || [["--城市--", 0]], {}, class: "city-select" %>
    <%= f.select :area, ChinaCity.list(f.object.city).presence || [["--地区--", 0]], {}, class: "city-select" %>
</div>
<% end %>
You need to Sign in before reply, if you don't have an account, please Sign up first.