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 Marking Todo Items Complete

Undefined method completed_at even after creating db:migrate file

I have the same situation as Harrison Hondo had. When doing the migrate it did not show that the column was created like it did for Jason in the video. If I run db:migrate again, I get nothing returned. How do I make this work? Do I revert to the previous commit and start over? Can I just delete the migration file and create a new one? I am not sure what to do. Here is the error I am getting when I run rspec:


1) Completing todo items is successful when marking a single item complete Failure/Error: expect(todo_item.completed_at).to be_nil NoMethodError: undefined method completed_at' for #<TodoItem:0x5f9a408> # ./spec/features/todo_items/complete_spec.rb:8:inblock (2 levels) in <top (required)>'

Finished in 0.08 seconds 1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_items/complete_spec.rb:7 # Completing todo items is successful when marki ng a single item complete

2 Answers

Seth Reece
Seth Reece
32,867 Points

Hi Andrew,

You can try rake db:rollback then change your migration, then migrate. You can also run rails generate migration AddSomeColumnToAndExistingTable then migrate again once you have the proper column information in your file that was created.

There is more about this in the documentation.

Thanks so much, Seth! The db:rollback worked. I had to roll back both migrations, the db:migrate and the db:migrate RAILS_ENV=test. I ran the rspec on complete_spec.rb and it came up with the correct result. Thanks, again!