I've been working on putting together a collection of useful Rails templates to get up and running with certain Rails features. As nice as all of the available gems are, there is often separate configuration required. The idea here is to give one template to do all configuration for a given set of features.
The idea here isn't to make creating a new Rails app really fast, because you probably don't do it enough for that to be worthwhile. It's really so that you can generate an app and be confident that all of the configuration has been taken care of. If you find any bugs, which I'm sure there are, let me know or submit a pull request.
Here's what we've got so far.
To use these templates, you can either clone the repository to a local directory or use the GitHub URL to the raw text version.
$ git clone git@github.com:KenneyE/.rails-templates.git rails-templates
$ cd <wherever you want the app>
$ rails new <app-name> -m ~/path/to/template.rb
For example, if you were to use the devise
template, you would run
$ rails new devise-app -m ~/rails-templates/devise_template.rb
Go to https://github.com/KenneyE/.rails-templates and click the template you'd like to use. Then click the Raw
button and copy the resulting URL.
$ rails new <app-name> -m <template-url>
#####NOTE:
If you are using any of the templates that build a test framework for you, make sure to include the -T
tag to tell Rails not to include the default test framework. The above examples would then look like...
$ rails new <app-name> -T -m ~/path/to/test_template.rb
All templates add a few useful features like binding_of_caller
, better_errors
, pry-rails
, annotate
, and convert the database to postgres. That is IMPORTANT
They also all run bundle install
and then run
git init
git add -A
git commit -m "Initial commit"
Includes these gems in the test environment:
gem_group :development, :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
end
gem_group :test do
gem 'capybara'
gem 'guard-rspec'
gem 'launchy'
gem 'shoulda-matchers'
gem 'faker'
end
To use:
$ rails new test-app -T -m ~/.rails-templates/test_template.rb
Adds devise gem and runs rails generate devise:install
. Adds some stuff to development.rb
To use:
$ rails new test-app -m ~/.rails-templates/devise_template.rb
Adds gems:
gem 'backbone-on-rails'
gem 'ejs'
and runs:
rails generate "backbone:install --javascript"
rails generate "backbone:scaffold #{@app_name} --javascript"
Runs curl
on angular.js and angular-mocks.js. Moves them to assets/javascripts
directory:
$ curl 'https://code.angularjs.org/1.1.5/angular.js' -o 'app/assets/javascripts/angular.js'
$ curl 'https://code.angularjs.org/1.1.5/angular-mocks.js' -o 'app/assets/javascripts/angular-mocks.js'
Removes turbolinks and adds ng-app="<app-name>"
and <div ng-view>
to application.html.erb.
Adds gem bootstrap-sass
and adds necessary stuff to ./app/assets/stylesheets/application.css.scss
$ rails new test-app -m ~/.rails-templates/bootstrap_template.rb
There's also a handful of templates that have various combinations of these features. Pick and choose accordingly.