Showing posts with label fixtures. Show all posts
Showing posts with label fixtures. Show all posts

Saturday, 13 October 2007

SQL logic error: Rails fixtures

Just had a seemingly odd Rails test error:

Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader
Started
E/usr/lib/ruby/1.8/sqlite3/errors.rb:94:in `check': SQL logic error or missing database (SQLite3::SQLException)

Simple enough to fix- it turns out my primary key (the "id" column) in the test fixtures weren't unique.

If you get this error, check your fixtures!

del.icio.us Tags: , , , ,

Saturday, 21 April 2007

Cloning test database to development

When developing Rails, I like to keep all of my data in the test fixtures.

In order to copy them to the development database, use this command:
rake db:fixtures:load # Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y

Note it will wipe out the existing data.

This was found using the handy "rake -T" command, which lists all rake Rails commands.