erb除非给出不一致的结果

时间:2014-03-27 23:52:04

标签: ruby-on-rails erb

我看到了意想不到的事情,我无法解释。

我有以下代码:

<% unless task.complete %>
... do stuff ...
<% end %>

这可以按预期显示不完全属于父对象的任务对象。然而,在一个,只有一个案例,它没有。如果它不起作用,则抛出以下错误:

undefined method `encoding' for 1:Fixnum

Extracted source (around line #1):

1 <% unless task.complete %> 
2
3
4

代码始终有效,但只有一种情况。失败的情况是当一个特定的父对象被呈现时。父对象不起眼。它有完成和不完成的任务。但是其他父对象也是如此,但只有一个父对象产生错误。

有什么想法吗?

提前致谢!

编辑:从日志中添加完整的详细信息。

    SELECT "engineers".* FROM "engineers" WHERE "engineers"."id" = ? ORDER BY "engineers"."id" ASC LIMIT 1  [["id", 1]]
  Rendered tasks/_task.html.erb (1.1ms)
  Rendered engineers/show.html.erb within layouts/application (7.2ms)
Completed 500 Internal Server Error in 9ms

ActionView::Template::Error (undefined method `encoding' for 1:Fixnum):
    1: <% unless task.complete %>
    2:  <div class="panel panel-default">
    3:      <div class="panel-body">
    4:          <% case task.priority
  app/views/tasks/_task.html.erb:1:in `_app_views_tasks__task_html_erb__2551940590140316489_25250680'
  app/views/engineers/show.html.erb:48:in `_app_views_engineers_show_html_erb__2573349182138661268_27996040'


  Rendered /home/local/ANT/eppreece/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
  Rendered /home/local/ANT/eppreece/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
  Rendered /home/local/ANT/eppreece/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (7.3ms)

0 个答案:

没有答案