Friday, 19 December 2014

12 Tips of Christmas - 9 Custom Generators

Twelve Tips of Christmas - 9 Custom Generators

With an application template and the assistance of a gem, bootstrapping a brand new Rails app is very easy for us these days. I hadn't realised how spoilt we had become until I had to create one from scratch recently.

One of the nice things in our bootstrap process, is that I have a few generators running to install some custom templates for our application to utilise. Creating a generator command is pretty easy and can be done within a gem or within your own Rails app

We'll use our basic example which is to copy our usual Capistrano configuration templates over to our application folder:

Firstly, you'll need to extend Rails::Generators::Base and give it the root directory of your templates to copy over