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 Editing Todo Lists

Bob Finkle
Bob Finkle
2,787 Points

NoMethodError in TodoListsController#create undefined method `description' for #<TodoList:0x007fe22e0c8150>

My list shows up. (Empty) but when I go to create a new list I get that error above.

NoMethodError in TodoListsController#create
undefined method `description' for #<TodoList:0x007fe22e159e70>

Extracted source (around line #30):
28
29
30
31
32
33


    respond_to do |format|
      if @todo_list.save
        format.html { redirect_to @todo_list, notice: 'Todo list was successfully created.' }
        format.json { render :show, status: :created, location: @todo_list }
      else

Rails.root: /Users/coltonhagan/Documents/Projects/rubyTest/odot

Application Trace | Framework Trace | Full Trace
app/controllers/todo_lists_controller.rb:30:in `block in create'
app/controllers/todo_lists_controller.rb:29:in `create'
Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"G1ToroIAV3Ao8xC+iJEpRYyRtT1X0vrF+2J0JO1AwdnzdDAHJK+TqzeRspDWB5zH3aabXujRR9RSEplXBxK5xw==",
 "todo_list"=>{"title"=>"",
 "descrpition"=>""}

Help? I have a feeling I either installed something incorrectly or, I'm using a version of rails that isn't compatible with my code.

Brandon Barrette
Brandon Barrette
20,485 Points

is your code on github? Paste the link?

1 Answer

David Ker
David Ker
14,439 Points

Take a peek at your parameters at the bottom of your error message. Looks like your issue is just a simple ol' typo :) descrpition instead of description. Don't feel too bad, it's super easy to make this mistake!! Normally Rails error messages are very helpful, but in this case,it's kinda hard to infer what the actual issue is.

So if you take a peek at your migration file, you'll notice the line t.text :descrpition. There are a couple ways to fix this: -Although it's not the recommended way, one option is to just fix the line in this file, then run a few commands to drop the database, and recreate it. Obviously you wouldn't want to do this in a production database, or one where you have lots of migrations...but since you've only got the one migration file, you can do this. Once you edit the file, rake db:drop to drop the database, rake db:create to create the database again, and then rake db:migrate to run the migration with the correct column name. -The better/safer/recommended way is to create a new migration to rename the column. I'll leave this one up to you to research how to rename a column in a migration...it actually isn't too hard!

Hope that helps!