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 am getting this error instead of the unable to find link "Mark Complete" error that Jason is getting in the video. I have uploaded my work to github at https://github.com/hondoh/ODOT

F

Failures:

  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:0x007fc9813a2558>
     # ./spec/features/todo_items/complete_spec.rb:10:in `block (2 levels) in <top (required)>'

Finished in 0.17555 seconds
1 example, 1 failure

Failed examples:

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

Randomized with seed 19938

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

The changes did not register in your schema: https://github.com/hondoh/ODOT/blob/master/db/schema.rb

Make sure you run rake db:migrate and rake db:migrate RAILS_ENV=test successfully.

I don't understand why the changes would not have registered. These are the results from the two console commands that I used. I wasn't sure if they worked either so I tried using the commands again but when I type them in they only show me the warning and do not appear to do anything.

HarrisoondosMBP:odot hsh2692$ bin/rake db:migrate Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run gem pristine --all for better startup performance. == 20150310184650 AddCompletedAtToTodoItems: migrating ======================== == 20150310184650 AddCompletedAtToTodoItems: migrated (0.0000s) ===============

HarrisoondosMBP:odot hsh2692$ bin/rake db:migrate RAILS_ENV=test Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run gem pristine --all for better startup performance. == 20150310184650 AddCompletedAtToTodoItems: migrating ======================== == 20150310184650 AddCompletedAtToTodoItems: migrated (0.0000s) ===============

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

The last line "AddCompletedAtToTodoItems: migrated (0.0000s)" says the migration was done and the schema should be changed. It works on my machine when I download your code and adds this column properly.

I just downloaded my project files and ran the commands again and they worked this time and gave me a different result in the command line as well. I really appreciate all the help you've been giving me with this application. It would have been a nightmare without you.