【发布时间】:2018-01-17 09:14:12
【问题描述】:
我使用 Rails 5.1 和 ransack gem 的当前版本。
我有一个“统计”页面,我在其中显示工作,我想使用两个下拉选择字段实现过滤功能,1)年(2011-2018)和 2)月(1 月至 12 月)。我怎样才能做到这一点?
我在想类似的东西
# in statistics index view
<%= search_form_for @search do |f| %>
<%= f.grouping_fields(f.object.new_grouping) do |g| %>
<%= g.condition_fields(g.object.new_condition) do |c| %>
<%= # here the years dropdown list%>
<%= # here the months dropdown list%>
<% end %>
<% end %>
<% end %>
<%= f.submit "filter" %>
<% end %>
它应该是什么样子的?
【问题讨论】:
-
那些年是否与您的模特有关?目前,我看不出有任何嵌套输入的理由,您只需创建两个独立的下拉列表(年、月)...
-
是的,你是对的!我想的太复杂了……
-
@Trinity76 你的模型中有年份和月份列吗?
标签: ruby-on-rails ransack