Ruby on Rails语法错误,意外的输入结束,期望keyword_end end ^

时间:2019-01-14 05:52:43

标签: ruby-on-rails ruby

我正在遵循有关文件上传的本教程,突然遇到new.html.erb文件中的错误。

SyntaxError in ResumesController#new

/Users/iripple/upload/app/views/resumes/new.html.erb:34: syntax error, unexpected keyword_ensure, expecting keyword_end ensure ^~~~~~ 

/Users/iripple/upload/app/views/resumes/new.html.erb:36: syntax error, unexpected end-of-input, expecting keyword_end end ^

Extracted source (around line #34):
32

这是我的new.html.erb:

<div class="container">   
<% if !@resume.errors.empty? %>   
   <div>   

      <ul>   
         <% @resume.errors.full_messages.each do |msg| %>   
            <li><%= msg %></li>   
         <% end %>   
<div class="container">   
<% if !@resume.errors.empty? %>   
   <div>   

      <ul>   
         <% @resume.errors.full_messages.each do |msg| %>   
            <li><%= msg %></li>   
         <% end %>      </ul>   

   </div>   
<% end %>   

<div>   
   <%= form_for @resume, html: { multipart: true } do |f| %>   
      <%= f.label :name %>   
      <%= f.text_field :name %>   
      <br><br>   
      <%= f.label :attachment %>   
      <%= f.file_field :attachment %>   
      <br>   
      <%= f.submit "Save" %>   
   <% end %>   
</div>   
</div>  

1 个答案:

答案 0 :(得分:2)

<div class="container">   
    <% if @resume.errors.present? %>    
       <div>   
          <ul>   
             <% @resume.errors.full_messages.each do |msg| %>   
                <li><%= msg %></li>   
             <% end %>
            </ul>   
       </div>   
    <% end %>   

    <div>   
       <%= form_for @resume, html: { multipart: true } do |f| %>   
          <%= f.label :name %>   
          <%= f.text_field :name %>   
          <br><br>   
          <%= f.label :attachment %>   
          <%= f.file_field :attachment %>   
          <br>   
          <%= f.submit "Save" %>   
       <% end %>   
    </div>   
</div>