我们目前正在升级我们的rails版本,并且在我的一个date_select标记中遇到了一些奇怪的错误。date_select标记从2.1.2升级到2.3.8时
这里是罪魁祸首:
<%= 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
在配置文件#显示
显示应用程序/视图/人/ _upcoming_assignments.html.erb哪里第46行提出:
你有没有对象,当你没有想到它! 您可能预期了Array的一个实例。而评估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:
我试图追查这个问题,似乎当我把在生成错误: month数组中的月份选项。所以当我这样做时:order => [:day,:year]页面加载完美。
我已经搜索了确切的问题,但更多的是前端deisgner,我不知道如何处理这一点。这是我的代码错误?或者这是一个不赞成的方法?
这里是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'
我用Google搜索有关unmemoized月份名称,但我发现错了。
好吧,我已经尝试拿出整个:order子句只是为了使事情工作。这一次它不会抛出错误,但标签不会出现!我试着检查irb,显然我的date_select标记没有返回任何选择标记,而只是一堆隐藏的标记!
我试图与默认轨道例如:
date_select("post", "written_on")
IRB返回此:
=> “\ n \ n \ n” 个
,你可以看到,没有选择标签任何地方。我尝试过datetime_select,并在那里看到一个选择标签。那么2.3.8的date_select有什么优势呢?
适用于me.check您的日期从数据库wheather是否正确也参考http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M002264 – Salil 2010-07-12 07:29:11
我试着看着这个,仍然徒劳无功。我试着看看rails的新i18n的东西,并做了config/locale/en.yml和config/initializers/locale.yml,我仍然得到相同的错误 – corroded 2010-07-12 09:06:37