Thursday, May 21, 2009

Running the Rails console in production mode

Whenever I needed to examine or modify records in a Rails production database, I always invoked the mysql directly. I found out today that you can run the Rails console in production mode. This means that you can create model instances and call methods off of them directly. Just call the script with the desired environment as an argument:

~/railsapp]$ ./script/console production

Rolling back database changes after exiting

If you start the console with the '--sandbox' option, any database changes you make will be rolled back when you exit. This allows you to try some funky things on your data.

~/railsapp]$ ./script/console --sandbox

I found these tips, and more at this blog post (kind of old, but still very useful).

No comments:

Post a Comment