form_tag中有两个select_date

时间:2015-11-21 20:12:21

标签: ruby-on-rails ruby

我有一个带有两个“select_date”的form_tag

<%= form_tag installation_path, :method => :get, :class => 'form-search' do %>
<%= select_date(date = Date.current, options = {}, html_options = {}) %>
<%= select_date(date2 = Date.current, options = {}, html_options = {}) %>

在后端我没有收到date2,我只收到日期,但在视图2中显示select_date。当我检查params我只看到1而我不知道为什么

{"utf8"=>"✓", "date"=>{"day"=>"21", "month"=>"11", "year"=>"2015"}...}

1 个答案:

答案 0 :(得分:1)

使用前缀:

<%= form_tag installation_path, :method => :get, :class => 'form-search' do %>
<%= select_date(Date.current, prefix: "date1") %>
<%= select_date(Date.current, prefix: "date2") %>

你会得到:

{"utf8"=>"✓", "date1"=>{"day"=>"21", "month"=>"11", "year"=>"2015"}, "date2"=>{"day"=>"21", "month"=>"11", "year"=>"2015"}...}