所以,我有這樣的代碼在「應用程序/視圖/帖」的部分稱爲「_form.html.erb」:Rails partials:我做錯了什麼?
<%= form_for @post do |f| %>
<% if @post.errors.any? %>
<h2>Errores:</h2>
<ul>
<% @post.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<% end %>
<p>
<%= f.label :title %><br />
<%= f.text_field :title %><br />
<br />
<%= f.label :content %><br />
<%= f.text_area :content %>
</p>
而且我有這個代碼的兩種觀點:
「應用程序/視圖/職位/ new.html.erb」
<h1>Nuevo post</h1>
<%= render 'form' %>
<p>
<%= f.submit "Agregar Nuevo Post" %>
</p>
<% end %>
「應用程序/視圖/職位/ edit.html.erb」
<h1>Editar Post</h1>
<%= render 'form' %>
<p>
<%= f.submit "Actualizar Post" %>
</p>
<% end %>
我要的是在視圖中渲染的形式,但與代碼,我已經證明給你我得到的服務器這個錯誤輸出:
SyntaxError in Posts#new
Showing /home/levick/rubyblog/app/views/posts/new.html.erb where line #10 raised:
/home/levick/rubyblog/app/views/posts/new.html.erb:10: syntax error, unexpected keyword_ensure, expecting $end
Extracted source (around line #10):
7: </p>
8: <% end %>
Trace of template inclusion: app/views/posts/new.html.erb
Rails.root: /home/levick/rubyblog
Application Trace | Framework Trace | Full Trace
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
,與同一編輯視圖。
我的問題是:我做錯了什麼?
謝謝!
不起作用... – Zauu
您收到了什麼錯誤? –
查看:http://min.us/mHje7Wu5B – Zauu