我正在遵循有关文件上传的本教程,突然遇到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>
答案 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>