我们目前正在升级我们的Rails版本,我在一个日期选择标签中遇到了一些奇怪的错误。
罪魁祸首是:
<%= date_select :consultant_assignment, :start_date, :order => [:day, :month, :year],
:start_year => 5.years.ago.year, :end_year => 5.years.from_now.year, :use_short_month => true %>
这会引发如下错误:
NoMethodError
在配置文件中显示
显示app/views/people/u即将到来的_assignments.html.erb,其中第46行出现:
当你没有预料到它的时候,你就没有了!
可能需要数组的实例。
计算nil.size时出错
提取源(在第46行附近):
43: <label for="consultant_assignment_start_date"><%= _('Start') %>:</label>
44: <% debugger %>
45:
46: <%= date_select :consultant_assignment, :start_date, :order => [:day, :month, :year], :start_year => 5.years.ago.year, :end_year => 5.years.from_now.year, :use_short_month => true %>
47:
48:
49:
我试图跟踪这个问题,当我在:order数组中放入:month选项时,似乎产生了错误。因此,当我执行:order=>[:day,:year]操作时,页面将完美加载。
我一直在寻找确切的问题,但作为一个前端设计师,我不知道如何继续这样做。这是我的代码错误吗?或者它是一个弃用的方法?
这里是
application trace
:
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:746:in `_unmemoized_month_names'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/memoizable.rb:72:in `month_names'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:781:in `month_name'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:708:in `select_month'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:705:in `upto'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:705:in `select_month'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:898:in `send'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:898:in `build_selects_from_types'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:896:in `each'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:896:in `build_selects_from_types'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:646:in `select_date'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/date_helper.rb:920:in `to_date_select_tag_without_error_wrapping'
我在谷歌上搜索了一些未被删除的月份名称,但我找到了娜达。
好吧,我试着去掉了全部的:命令条款,只是为了让该死的东西工作。这次它不会抛出错误,但不会显示标签!我试过签入IRB,显然我的日期选择标签没有返回任何选择标签,只是一堆隐藏的标签!
我用默认的Rails示例尝试了这个方法:
date_select("post", "written_on")
IRB返回:
= \\gt;\\n\n\n
如您所见,任何地方都没有选择标记。我尝试了datetime_select,在那里看到了一个select标记。那么2.3.8的日期选择是什么?