Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

NoMethodError in Statuses#new : Complete Ruby on Rails build a simple web app

NoMethodError in Statuses #new

Showing /Users/ScottDAlessandro/code/treebook/app/views/statuses/_form.html.erb where line #16 raised:

undefined method `full_name' for #<Status:0x0000010376cc40> Extracted source (around line #16):

13: 14: <div class="field"> 15: <%= f.label :full_name %><br /> 16: <%= f.text_field :full_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/ScottDAlessandro/code/treebook

Application Trace | Framework Trace | Full Trace app/views/statuses/form.html.erb:16:in `block in _app_views_statusesform_html_erb871609707240624879_2176560820' app/views/statuses/_form.html.erb:1:in `_app_views_statusesform_html_erb871609707240624879_2176560820' app/views/statuses/new.html.erb:3:in `_app_views_statuses_new_html_erb_3089828772916649988_2174583640' app/controllers/statuses_controller.rb:29:in `new' Request

Parameters:

None Show session dump

Show env dump

Response

<%= 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>

I get this error when I try updating a status on my page. Here are a few other files I updated recently.

      <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 %>

db/migrate

class AddUserIdToStatuses < ActiveRecord::Migration
  def change
    add_column :statuses, :user_id, :integer
    add_index :statuses, :user_id
    remove_column :statuses, :name
  end
end

Sorry for a poor description but I am lost for words on this error. I am not 100% when this error surfaced, it seemed everything was going fairly smoothly throughout the project. Does anyone know where I could have went wrong or why I am getting this error? Thanks :)

1 Answer

What does your user.rb file look like?

If you have recently added the full_name method, you may need to delete all statuses.