mercredi 8 juillet 2015

Mysql2 error while using RSpec fixtures

I've added a dependency to both order and order_items fixtures (which already existed), but I'm receiving the following error every time I run my rspec worker test.

ActiveRecord::StatementInvalid:
       Mysql2::Error: Table 'inventory_test10.order_packages' doesn't exist: SHOW FULL FIELDS FROM `order_packages` /*controller:,action:,line:*/

I have an order which has many order_items and many order_packages. order_items also belong to order_packages. Therefore, I am able to do:

order.order_items.each do |oi|
  put oi.order_package.status
end

The original issue was that status wasn't recognized for nil class because an order_packages.yml fixture was never created. I've tried several rake tasks, but I'm not super familiar with fixtures, migrations, rake tasks, etc and I'm not sure if I accidentally caused the error running multiple taks. Below is a snippet from a blog that warned about running the command multiple times - http://ift.tt/1zL1LUS:

rake db:fixtures:load FIXTURES=credit_card_types

A word of warning, if we run this command multiple times, it will seed the table multiple times. It’s not idempotent.

Other tasks I ran:

  • FIXTURES=orders; rake db:fixtures:load
  • rake db:fixtures:dump (didn't work - error)
  • rake db:fixtures:drop (didn't work - error)

Thanks in advance for any suggestions!

Aucun commentaire:

Enregistrer un commentaire