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

Ruby Build a Simple Ruby on Rails Application Customizing Forms Getting the Latest Changes

jarrod Reeves
jarrod Reeves
6,357 Points

The new status page is producing an error.

I am getting the error in the _form.html.erb code. It says an undefined method in the code. This is the _form.html.erb code

<%= 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 |message| %>
        <li><%= message %></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_field :content %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

It says undefined method for the name on line 16.

1 Answer

Brandon Barrette
Brandon Barrette
20,485 Points

I'm pretty sure you remove :name and put in :user_id shortly. Looking at that video, I don't see anything in that video dealing with the status form. So I'd hang tight for now, the error will be fixed.

Also note that the videos you are watching are written for Rails 3, and most likely you've downloaded the newest version of Rails 4 (maybe 4.1 or 4.2).

You're going to run into a lot of headaches using Rails 4 with these videos because there have been some major changes. Search the forums here for help because many good answers have been already posted.

I also recommend doing the ODOT tutorials first as they are written for Rails 4. Then when you have a handle on Rails, you can go back to these videos and know what needs to be changed to make things work.

jarrod Reeves
jarrod Reeves
6,357 Points

Is it possible to change the version of Rails to the version they are using in the videos?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Yes. You first have to install the specific version of rails by doing gem install rails -v 3.2.6 and then generating a new app by entering rails _3.2.6_ new treebook (including the underscores). 3.2.6 is the exact version used in the videos. You will also notice that the use older Bootstrap (v 2-something). You may want to find it - lots of stuff they do in the UI (css selectors) don't work in the newest Bootstrap.