Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 将日期作为单个元素而不是年、月和日进行搜索_Ruby On Rails_Ruby_Form Helpers - Fatal编程技术网

Ruby on rails 将日期作为单个元素而不是年、月和日进行搜索

Ruby on rails 将日期作为单个元素而不是年、月和日进行搜索,ruby-on-rails,ruby,form-helpers,Ruby On Rails,Ruby,Form Helpers,我正在尝试将日期搜索添加到一个小型rails项目中。为此,我使用了一个form_标签: <%= form_tag posts_path, :method => 'get' do %> <p> <%= select_date Date.today, prefix: :start_date %> <%= submit_tag "Search", :name =>nil %> &

我正在尝试将日期搜索添加到一个小型rails项目中。为此,我使用了一个form_标签:

<%= form_tag posts_path, :method => 'get' do %>
    <p>     
        <%= select_date Date.today, prefix: :start_date %>  
        <%= submit_tag "Search", :name =>nil %> 
    </p>
<%end%>
有没有办法将url中的搜索参数组合成一个日期,使url看起来像这样

http://localhost:3000/posts?utf8=%E2%9C%93&start_date=2013-06-01

你为什么要这么做<代码>参数[:开始日期]无论如何都将是
日期
start_date=2013-06-01
将是一个
String
,您必须自己解析它(包括错误处理)。它是指定url格式以具有上述日期参数的赋值的一部分。我认为,因为url需要包含2个日期和一个整数作为搜索参数,而不是使用
select\u date
,而是使用
text\u字段
,并通过类似的方式改进UI。
http://localhost:3000/posts?utf8=%E2%9C%93&start_date=2013-06-01