0
我正在關注的jumpstartlabs blogger tutorial一個NoMethodError和我到部分i5和與得到的作者#新如何調試在軌
這裏,NoMethodError掙扎是堆棧跟蹤:
NoMethodError in Authors#new
Showing /home/.../blogger/app/views/authors/_form.html.erb where line #16 raised:
undefined method `username' for #<Author:0xb6379068>
Extracted source (around line #16):
<div class="field">
<%= f.label :username %><br>
<%= f.text_field :username %>
</div>
<div class="field">
<%= f.label :email %><br>
Trace of template inclusion: app/views/authors/new.html.erb
的new.html.erb是非常簡單的
<h1>New Author</h1>
<%= render 'form' %>
<%= link_to 'Back', authors_path %>
這裏是我的_form.html.erb
<%= form_for(@author) do |f| %>
<% if @author.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@author.errors.count, "error") %> prohibited this author from being saved:</h2>
<ul>
<% @author.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :username %><br>
<%= f.text_field :username %>
</div>
<div class="field">
<%= f.label :email %><br>
<%= f.text_field :email %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
我真的很想知道我可以在rails控制檯中進行調試。或者如何讀取蹤跡以找出這種現象的原因。如果需要,我可以附加更多的完整痕跡,但時間很長。
謝謝,它看起來像我的移徙是不正確的。 我更新了它,運行 rake db:migrate:reset 它被修復了,謝謝 – 2015-04-04 15:16:11