【发布时间】:2018-11-14 21:53:54
【问题描述】:
您好,亲爱的所有 Rails 社区。我使用城邦 gem 为国家和州制作下拉菜单。我看过 this tutorial 和 this github samples 。在示例代码中,它就像 belov;
<div class="field">
<!-- Country -->
<%= f.label :country %>
<%= selected_tag :country, options_for_select(CS.countries.map { |c| [c[1], c[0]] } ) %>
</div>
<div class="field">
<!-- State -->
<%= label_tag :state %>
<%= selected_tag :state, options_for_select([]) %>
</div>
所以我将“selected_tag”名称更改为“f.selected”
<div class="field">
<!-- Country -->
<%= f.label :country %>
<%= f.select :country, options_for_select(CS.countries.map { |c| [c[1], c[0]] } ) %>
</div>
<div class="field">
<!-- State -->
<%= label_tag :state %>
<%= f.select :state, options_for_select([]) %>
</div>
现在不工作了。
关于问题的详细信息:当您选择任何国家/地区时,它会从国家/地区获取状态。但是当我将名称从“selected_tag”更改为“f.select”时,它现在没有得到状态。它看起来很空
你能检查一下链接并告诉我为什么不工作吗?
谢谢。
【问题讨论】:
-
除了缩进,它们对我来说看起来一样吗?当您说“不工作”时,会发生什么 - 任何错误或其他行为?
-
抱歉。当您选择任何国家/地区时,它会从国家/地区获取状态。但是当我将名称从“selected_tag”更改为“f.select”时,它现在没有得到状态。它看起来很空。
标签: ruby-on-rails