tag:blogger.com,1999:blog-8941983.post-1327098898137639222007-09-09T14:47:00.000+04:002007-09-10T14:55:55.862+04:00How to run rake tasks for non-development rails environmentsI’ve found that parameters passed to rake tasks in the form “name=value” are converted into the environment variables. This magic is done by rake itself when parsing command-line parameters. It has an interesting consequence – you can run some db-oriented rake tasks for any of your ruby on rails environments. For instance, to migrate your production database to the latest version you can run:<br /><pre>rake db:migrate RAILS_ENV=production</pre><br />This knowledge is also useful when writing custom rake tasks; you can access environment variables using predefined ENV hash (you can also access rake command line parameters using ARGV hash).<br /><br /><small><br /><a href="http://technorati.com/tag/rake" rel="tag">rake</a> <a href="http://technorati.com/tag/ruby+on+rails" rel="tag">ruby on rails</a> <a href="http://technorati.com/tag/ror" rel="tag">ror</a> <a href="http://technorati.com/tag/rails" rel="tag">rails</a><br /></small>Kir Maximovhttp://www.blogger.com/profile/11739397709323043771noreply@blogger.com