Technology and Software

Stored procedures on Rails

Time ago I learnt how to use stored procedures in Ruby on Rails, but I couldn’t understand how to use them in test. rake test consistently failed to copy my stored procedures from the development to the test database so there was little left to test there.

After upgrading to Rails 1.1.6 I started a new project and this time I made it.

The winning move was uncommenting this line in environment.rb

config.active_record.schema_format = :sql

Rails creates the db/development_structure.sql file now which contains my development database structure, stored procedures included. When I run rake test it uses this file to create the test database and the test code has all it needs to run.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s