Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Paul Dietrich
4,557 PointsNoMethodError in Statuses#new
Hello,
This morning, when I started by rails server, I accessed localhost:3000 and did not see any of the comments that I had posted before. I thought this was strange, but didn't think much of it. When I went to click on the Post A New Status button, I am directed to a page that shows the following:
NoMethodError in Statuses#new
Showing /Users/pauldietrich/Documents/Projects/treebook/app/views/statuses/_form.html.erb where line #16 raised:
undefined method `name' for #<Status:0x007fa864405240> Extracted source (around line #16):
13: 14: <div class="field"> 15: <%= f.label :name %><br /> 16: <%= f.text_field :name %> 17: </div> 18: <div class="field"> 19: <%= f.label :content %><br /> Trace of template inclusion: app/views/statuses/new.html.erb
Rails.root: /Users/pauldietrich/Documents/Projects/treebook
Application Trace | Framework Trace | Full Trace app/views/statuses/form.html.erb:16:in `block in _app_views_statusesform_html_erb967673679810272840_70180605850480' app/views/statuses/_form.html.erb:1:in `_app_views_statusesform_html_erb_967673679810272840_70180605850480' app/views/statuses/new.html.erb:3:in `_app_views_statuses_new_html_erb_2428759276343217490_70180605805460' app/controllers/statuses_controller.rb:29:in `new'
My _form.html.erb file looks like this:
<%= form_for(@status) do |f| %> <% if @status.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@status.errors.count, "error") %> prohibited this status from being saved:</h2>
<ul>
<% @status.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field"> <%= f.label :name %><br /> <%= f.text_field :name %> </div> <div class="field"> <%= f.label :content %><br /> <%= f.text_area :content %> </div> <div class="actions"> <%= f.submit %> </div> <% end %>
Any suggestions as to why this is going on would be great!
3 Answers
Jason Seifer
Treehouse Guest TeacherHey Paul, try following along with Jim in this video - http://teamtreehouse.com/library/programming-2/build-a-simple-version-of-facebook/customizing-forms/getting-the-latest-changes. Thanks!
Jonathan Wilson
5,437 PointsThis helped me too. Thanks!
Jennifer Fry
9,855 PointsMe as well! (although it would have been nice going into this chapter knowing that errors would result from Jason's work in the previous). At least you keep us on our toes! ;)