Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Running more than one rake task at once?

Been loving rails, but still struggling with how long it takes to run tasks from the command line.

I'm wondering if it's possible to combine multiple rake tasks without reloading the environment each time. For example, if I run

rails generate rspec:install && rails generate model test_model title:string && rake db:migrate

it will spend 10 seconds loading up rails to run the rspec install, then another ten seconds to load up the environment for generate model, then another for the migration. Is there a way to keep the same environment open for all 3 commands?

like image 369
PlankTon Avatar asked Sep 14 '11 13:09

PlankTon


1 Answers

Take a look at the rails-sh gem - it boots the Rails environment, and then presents a command line interface, so you can run your command within it. There are limitations when using it (I don't think you can change your RAILS_ENV), but for your use-case, it should be perfect.

If your commands are just rake tasks, you can use spaces to separate them, e.g.:

rake db:migrate && rake db:test:clone_structure

would become

rake db:migrate db:test:clone_structure
like image 55
Graham Savage Avatar answered Nov 19 '22 14:11

Graham Savage