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