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,429 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,429 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.