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 Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Adding Validations to Todo Items

Matthew Slaton
PLUS
Matthew Slaton
Courses Plus Student 963 Points

I am getting that the table content is undefined?

undefined local variable or method `content' for #<#<Class:0x5abbd10>:0x55dcda8>

4 Answers

John Steer-Fowler
PLUS
John Steer-Fowler
Courses Plus Student 11,734 Points

Hi Matthew,

Could you post your ruby code as an answer here so I can take a look at it please?

Will do my best to help

Matthew Slaton
PLUS
Matthew Slaton
Courses Plus Student 963 Points

Thanks, the full error is:

 1) Adding todo items is successful with valid content
     Failure/Error: click_link "New Todo Item"
     ActionView::Template::Error:
       undefined local variable or method `content' for #<#<Class:0x5ae7a68>:0x586f500>
     # ./app/views/todo_items/new.html.erb:3:in `block in _app_views_todo_items_new_html_erb__443144078_46362060'
     # ./app/views/todo_items/new.html.erb:1:in `_app_views_todo_items_new_html_erb__443144078_46362060'
     # ./spec/features/todo_items/create_spec.rb:15:in `block (2 levels) in <top (required)>'
Matthew Slaton
PLUS
Matthew Slaton
Courses Plus Student 963 Points

new.html.erb has:

%= form_for [@todo_list, @todo_item] do |form| %>
 %= form.label :content %>
 %= form.text_field content %>

 %= form.submit "Save" %>
% end %>
John Steer-Fowler
PLUS
John Steer-Fowler
Courses Plus Student 11,734 Points

Hi Matthew,

Your code here:

<%= form.text_field content %>

Should be this:

<%= form.text_field :content %>

Hope this helps