【问题标题】:Rails syntax error missing parenthasizesRails 语法错误缺少括号
【发布时间】:2013-08-24 23:08:00
【问题描述】:

我从我不理解的 Rails 中得到一个奇怪的语法错误。

得到以下错误:

显示 /home/action/workspace/clinio/app/views/tasks/_task.html.erb 提出第 3 行的位置:

/home/action/workspace/clinio/app/views/tasks/_task.html.erb:3:语法错误,意外';',期待':' ';@output_buffer.append=( 图像... ^

提取的源代码(第 3 行附近):

  <% @uncompletedtasks = @task if @uncompletedtasks?%>
  <li id="task_"> 
    <div><%= image_tag "26-mini-gray-checkmark.png" %> 
        <a href="<%=task_path(@uncompletedtasks)%>"> <%= @uncompletedtasks.task %> </a>
    </div>
  </li>

模板包含的痕迹:app/views/tasks/_task.html.erb、app/views/layouts/application.html.erb

Rails.root:/home/action/workspace/clinio

应用程序跟踪 |框架跟踪 |全跟踪 app/views/layouts/application.html.erb:35:in _app_views_layouts_application_html_erb__122972711486791642_46610700' app/controllers/users_controller.rb:16:inindex'

【问题讨论】:

    标签: ruby-on-rails syntax


    【解决方案1】:

    最后不需要那个问号。

    <% @uncompletedtasks = @task if @uncompletedtasks %>
    

    (不过,我仍然无法理解这段代码的用途。为什么只有当 @uncompletedtasks 有价值时才想覆盖它?)

    【讨论】:

    • sergio 感谢您指出我明显的错误 :) 对我来说不是那么明显!多亏了你,我改变了一些东西,现在它可以工作了
  • @mattclar: 这是我的荣幸 :)
  • 猜你喜欢
    相关资源
    最近更新 更多
    热门标签