Pages#home中的SyntaxError

时间:2013-04-04 21:13:11

标签: ruby-on-rails ruby localhost syntax-error

*当我保存Sublime文本并刷新localhost:3000时,我不断收到此错误。我该怎么办?


显示/Users/Matt/code/omrails/app/views/layouts/application.html.erb,其中#21 行被提升:

/Users/Matt/code/omrails/app/views/layouts/application.html.erb:21: syntax error, unexpected keyword_ensure, expecting keyword_end
/Users/Matt/code/omrails/app/views/layouts/application.html.erb:23: syntax error, unexpected $end, expecting keyword_end

提取的来源(在#21 附近):

18:         </div>
19:     </body>
20: </html>

模板包含跟踪:app / views / layouts / application.html.erb


这是我的 application.html.erb 文件的样子:

<!DOCTYPE html>
<html>
<head>
  <title>One Month Rails</title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>
    <%= render "layouts/header" %>

    <div class="container">
        <% flash.each do |name, msg| %>
            <%= content_tag(:div, msg, class: "alert alert-#{name}") %>
        <%= yield %>

        <%= render "layouts/footer" %>
    </div>
</body>


我做错了什么???

2 个答案:

答案 0 :(得分:0)

<% flash.each do |name, msg| %>
    <%= content_tag(:div, msg, class: "alert alert-#{name}") %>
<% end %>

答案 1 :(得分:0)

您忘记了end

flash.each do

我是下一个正确的观点

<!DOCTYPE html>
<html>
<head>
  <title>One Month Rails</title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>
    <%= render "layouts/header" %>

    <div class="container">
        <% flash.each do |name, msg| %>
            <%= content_tag(:div, msg, class: "alert alert-#{name}") %>
        <% end %>
        <%= yield %>

        <%= render "layouts/footer" %>
    </div>
</body>