Grunt Rails

How to Get Grunt to Start Your Rails Server

Getting Grunt to start your Rails server is extremely simple and quick if you just know how.

By the way, you might want to check out my How to Wire Up Ruby on Rails and AngularJS as a Single-Page Application tutorial┬ábefore you proceed. I realize your existing Gruntfile.js setup might be different from mine, and I frankly have no idea if what I’m suggesting here will work if your setup differs.

First you’ll need to install grunt-shell-spawn:

Next, add this to your Gruntfile.js:

Then, inside the grunt.initConfig part, add this:

Lastly, add shell:startRailsServer to the server task.

Now, when you run grunt serve, you should end up with both localhost:9000 and localhost:3000. (Again, if your Gruntfile.js setup is different from mine, I can’t guarantee that you’ll get the same result. If you know try my suggestion with a different setup, leave me a comment and let me know how it goes.)

Here’s my complete Gruntfile.js for reference.

 

About the author

Jason Swett

5 Comments

Click here to post a comment