Rails 3.2 Application Templates
These application generator templates give you a Rails 3.2 starter app you can deploy in minutes.
Templates
These Rails application templates from the RailsApps project generate an example Rails app that can be used as a starter app.
Author | Example App | Tutorial | Comments |
---|---|---|---|
Brook Riggio | Haml, HTML5, Twitter Bootstrap | Uses ActiveRecord and SQLite | |
Daniel Kehoe | Devise, RSpec, Cucumber | Tutorial | Uses ActiveRecord and SQLite |
Daniel Kehoe | Devise, CanCan, Twitter Bootstrap | Tutorial | CanCan for admin authorization |
Daniel Kehoe | Devise, Mongoid | Tutorial | Combines Devise with MongoDB |
Daniel Kehoe | OmniAuth, Mongoid | Tutorial | OmniAuth for authentication with a MongoDB datastore |
Daniel Kehoe | Subdomains, Devise, Mongoid | Tutorial | Basecamp-style subdomains with Devise and MongoDB |
These application templates were created using the Rails Apps Composer gem which provides a convenient way to assemble a reusable application template by selecting various “recipes” to include popular Rails development gems.
Follow on Twitter
Follow the project on Twitter: @rails_apps. Please tweet some praise if you like what you’ve found.
Template Options
The application generator templates will ask you for various preferences:
- Would you like to use Haml instead of ERB?
- Would you like to use RSpec instead of TestUnit?
- Would you like to use factory_girl for test fixtures with RSpec?
- Would you like to use machinist for test fixtures with RSpec?
- Would you like to use Cucumber for your BDD?
- Would you like to use Guard to automate your workflow?
- Would you like the app to use a GMail account to send email?
- Would you like to use Mongoid to connect to a MongoDB database?
- Would you like to use OmniAuth for authentication?
- Would you like to use Devise for authentication?
- No
- Devise with default modules
- Devise with Confirmable module
- Devise with Confirmable and Invitable modules
- Would you like to manage authorization with CanCan & Rolify?
- Which front-end framework would you like for HTML5 and CSS3?
- None
- Zurb Foundation
- Twitter Bootstrap – less
- Twitter Bootstrap – sass
- Skeleton
- Normalize CSS for consistent styling
- Which form gem would you like?
- None
- simple form
- simple form (bootstrap)
- Would you like to use rails-footnotes during development?
- Would you like to set a robots.txt file to ban spiders?
- Would you like to add support for subdomains?
- No
- One subdomain per user (like Basecamp)
Suggested Use
You can quickly generate a Rails web application using just the rails new
command. In practice, experienced Rails developers typically add an assortment of useful additional packages (known as RubyGems, or just “gems”) before beginning development of any web application. A developer often uses the same set of gems to get started and may create a “starter app” that can be copied and reused for any new project. Often a developer will create an “application template” to automate the creation of starter apps.
Rails application templates are Ruby scripts used with the "rails new myapp -m"
command to generate a Rails web application.
Application templates commonly integrate popular gems that many Rails developers include in a starter app. It can be a hassle to integrate some of the most commonly used gems, particularly when new versions are released and there are minor “gotchas” that interfere with gems working together. By using these application templates, you’ll have a ready-to-run app without the integration “gotchas”. Each has a detailed tutorial so you’ll see exactly how the application was assembled.
You can use the application templates from this repository to generate a starter app directly. You can edit the templates to customize the script to generate a customized starter app. Or you can use the Rails Apps Composer gem to assemble a selection of recipes for a customized starter app.
Dependencies
Before generating your application, you will need:
- The Ruby language (version 1.9.3)
- Rails 3.2
See Installing Rails 3.2 for detailed instructions and advice.
Generating the Application
Use the "rails new myapp -m"
command to generate a Rails web application.
This creates a new Rails app (with the myapp
name you provide) on your computer.
You can add the -T -O
flags to skip Test::Unit files and Active Record files.
Template for Rails 3 + Haml + HTML5
This application template will offer you a choice of Haml or ERB, give you options for a CSS front-end framework such as Twitter Bootstrap, and create a default application layout using HTML5:
$ rails new myapp -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-haml-html5-template.rb
Template for Rails 3 + Devise + RSpec + Cucumber
To build the rails3-devise-rspec-cucumber example application, run the command:
$ rails new myapp -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-devise-rspec-cucumber-template.rb -T
Use the -T
flag to skip Test::Unit files.
Template for Rails 3 + Twitter Bootstrap + Devise + CanCan
To build the rails3-bootstrap-devise-cancan example application, run the command:
$ rails new myapp -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-bootstrap-devise-cancan-template.rb -T
Use the -T
flag to skip Test::Unit files.
Template for Rails 3 + Mongoid + Devise
To build the rails3-mongoid-devise example application, run the command:
$ rails new myapp -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-mongoid-devise-template.rb -T -O
Use the -T -O
flags to skip Test::Unit files and Active Record files.
Template for Rails 3 + Mongoid + OmniAuth
To build the rails3-mongoid-omniauth example application, run the command:
$ rails new myapp -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-mongoid-omniauth-template.rb -T -O
Use the -T -O
flags to skip Test::Unit files and Active Record files.
Template for Rails 3 + Subdomains
To build the rails3-subdomains example application, run the command:
$ rails new myapp -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-subdomains-template.rb -T -O
Use the -T -O
flags to skip Test::Unit files and Active Record files.
Application Template Default
The rails new
command creates a new Rails application. If you want to use a template for every Rails application you build, you can set options for the rails new
command in a .railsrc file in your home directory. Here’s how to set up a .railsrc file to use the rails3-haml-html5 template when you create a new Rails application:
# ~/.railsrc -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-haml-html5-template.rb
Troubleshooting
Problems? Check the issues.
Problems with Rake
If you see:
The template ... could not be loaded. Error: You have already activated rake 0.8.7, but your Gemfile requires rake 0.9.x. Consider using bundle exec.
If you are using Ruby 1.9.2, you must update the standard Ruby installation from Rake 0.8.7 to Rake 0.9.2 (or newer) before using the application templates to generate a new Rails app. It’s advisable to update to Ruby 1.9.3 which will provide Rake 0.9.2. See Installing Rails 3.2.
Problems with “Certificate Verify Failed”
Are you getting an error “OpenSSL certificate verify failed” when you try to generate a new Rails app from an application template? See suggestions to resolve the error Certificate Verify Failed.
Documentation and Support
This is the only documentation.
The Recipes
For your reference, here’s an annotated list of available recipes for the Rails Apps Composer gem. For an up-to-date list, browse the repository recipes directory.
Customizing the Template
If you wish to “change the recipe” to generate the app with your own customized options, you can copy and edit the template file. However, it is better to use the Rails Apps Composer gem to create a new application template. You’ll find newer versions of the recipes that make up the application template. You may find issues have been identified and (perhaps) fixed. And it will be easier to maintain your application template if you work from the Rails Apps Composer gem.
Writing Recipes
To understand the code in these templates, take a look at Thor::Actions. Your recipes can use any methods provided by Thor::Actions or Rails::Generators::Actions.
About Rails Application Templates
Cooking Up A Custom Rails 3 Template (11 Oct 2010) by Andrea Singh
Rails Application Templates (16 Sept 2010) by Collin Schaafsma
Application templates in Rails 3 (18 Sept 2009) by Ben Scofield
Railscasts: App Templates in Rails 2.3 (9 Feb 2009) by Ryan Bates
Rails templates (4 Dec 2008) by Pratik Naik
Similar Projects
There are many similar projects. Here’s an annotated list of other Rails application template projects and Rails examples, tutorials, and starter apps.
Issues
Any issues? Please create an issue on GitHub.
Where to Get Help
Your best source for help with problems is Stack Overflow. Your issue may have been encountered and addressed by others.
You can also try Rails Hotline, a free telephone hotline for Rails help staffed by volunteers.
Contributing
If you make improvements to these application templates, or create a new one, please share with others.
Send the author a message, create an issue, or fork the project and submit a pull request.
If you add functionality to this application, create an alternative implementation, or build an application that is similar, please contact me and I’ll add a note to the README so that others can find your work.
Credits
Daniel Kehoe (http://danielkehoe.com/) initiated the project.
Are the templates useful to you? Follow the project on Twitter:
@rails_apps
and tweet some praise. I’d love to know you were helped out by what I’ve put together.
Contributors
Brook Riggio contributed the rails3-haml-html5 template.
License
Public Domain Dedication
This work is a compilation and derivation from other previously released works. With the exception of various included works, which may be restricted by other licenses, the author or authors of this code dedicate any and all copyright interest in this code to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this code under copyright law.