• Stars
    star
    3,384
  • Rank 12,656 (Top 0.3 %)
  • Language
    Ruby
  • Created almost 12 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rails Composer. The Rails generator on steroids for starter apps.

Rails Composer Rails Composer

An application template that creates starter applications for Rails.

It’s the Rails generator on steroids.

Watch the videos:

Sign up for the Rails Composer mailing list Join the RailsApps Project
Rails Composer mailing list Support the project

From the RailsApps Project

The RailsApps open source project offers starter applications and tutorials for Rails developers. Generate the applications with the Rails Composer tool.

All the code is explained in the Capstone Rails Tutorials. You can purchase the Capstone Rails Tutorials to support the project.

Sign up for the Rails Composer mailing list for news and announcements.

Starter Apps and Tutorials

Example Tutorial Comments
learn-rails Learn Ruby on Rails from the book for beginners
rails-bootstrap Rails and Bootstrap Bootstrap front-end framework
rails-foundation Rails and Foundation Foundation front-end framework
rails-mailinglist-activejob Mailing List with Active Job Tutorial sign up for a mailing list using background processing
rails-omniauth OmniAuth Tutorial authentication with OmniAuth
rails-devise Rails Devise Tutorial authentication with Devise
rails-devise-roles Role-Based Authorization authorization with roles
rails-devise-pundit Rails Pundit Tutorial authorization with Pundit
rails-signup-download Rails Signup Download Devise plus download a PDF file
rails-stripe-checkout Stripe Checkout selling a product with Stripe Checkout
rails-stripe-coupons Stripe JS With Coupons complex Rails and Stripe integration

The rails_apps_composer Gem

Do you want to customize the Rails Composer application template? The Rails Composer application template is built from recipes provided by the rails_apps_composer gem.

If You Are New to Rails

If you’re new to Rails, see What is Ruby on Rails?, the book Learn Ruby on Rails, and recommendations for a Rails tutorial.

Dependencies

Before running the Rails Composer tool, you need to install:

  • The Ruby language
  • Rails

Check that appropriate versions of Ruby and Rails are installed in your development environment:
$ ruby -v
$ rails -v

Be sure to read the article Installing Rails to make sure your development environment is set up properly.

How To Use Rails Composer

To build a Rails application using the Rails Composer tool:

$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

Replace myapp with the name of your application.

The $ character indicates a shell prompt; don’t include it when you run the command.

See the “Troubleshooting” section below if you see errors. In general, you’ll avoid problems if you create your application using RVM as described in the next section.

Creating a Starter App Using RVM

I recommend using RVM, the Ruby Version Manager, to manage your Rails versions, as described in the Installing Rails article.

Here’s how to generate a new Rails application using the Rails Composer tool and RVM:

$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.4.0@myapp --ruby-version --create
$ gem install rails
$ rails new . -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

Instead of installing Rails into the global gemset and running rails new, we’ll create a root directory for a new application, create a new gemset, install Rails, and then generate a starter application.

When we create the gemset, the option “—ruby-version” creates .ruby-version and .ruby-gemset files in the root directory. RVM recognizes these files in an application’s root directory and loads the required version of Ruby and the correct gemset whenever you enter the directory.

When we create the gemset, it will be empty (though it inherits use of all the gems in the global gemset). We immediately install Rails. The command gem install rails installs the most recent stable release of Rails.

Finally we run rails new .. We use the Unix “dot” convention to refer to the current directory. This assigns the name of the directory to the new application.

This approach is different from the way most beginners are taught to create a Rails application. Our approach makes it easy to create a project-specific gemset to avoid clashes between gem versions when using the Rails Composer tool.

Choose a RailsApps Starter Application

Use Rails Composer to generate any of the example applications from the RailsApps project. You’ll be able to choose your own project name when you generate the app. Generating the application gives you additional options.

To build the example application, Rails must be installed in your development environment.

You’ll see a prompt:

option  Build a starter application?
    1)  Build a RailsApps example application
    2)  Contributed applications
    3)  Custom application

Enter “1” to select Build a starter application. You’ll see a prompt:

option  Choose a starter application.
    1)  learn-rails
    2)  rails-bootstrap
    3)  rails-foundation
    4)  rails-mailinglist-activejob
    5)  rails-omniauth
    6)  rails-devise
    7)  rails-devise-roles
    8)  rails-devise-pundit
    9)  rails-signup-download
   10)  rails-stripe-checkout
   11)  rails-stripe-coupons

Each of these applications is available as an example in the RailsApps GitHub repo and each is accompanied by a tutorial on the Capstone Rails Tutorials site.

Make your choice. The Rails Composer tool may give you other options (other applications may have been added since these notes were written).

Options

The application generator template will ask you for additional preferences. Options vary, depending on the example application you build. Options may have changed in a newer version of Rails Composer.

 option  Web server for development?
       1)  WEBrick (default)
       2)  Thin
       3)  Unicorn
       4)  Puma
       5)  Phusion Passenger (Apache/Nginx)
       6)  Phusion Passenger (Standalone)
 option  Web server for production?
       1)  Same as development
       2)  Thin
       3)  Unicorn
       4)  Puma
       5)  Phusion Passenger (Apache/Nginx)
       6)  Phusion Passenger (Standalone)
 option  Database used in development?
       1)  SQLite
       2)  PostgreSQL
       3)  MySQL
 option  Template engine?
       1)  ERB
       2)  Haml
       3)  Slim
 option  Test framework?
       1)  None
       2)  RSpec with Capybara
 option  Front-end framework?
       1)  None
       2)  Bootstrap 3.0
       3)  Bootstrap 2.3
       4)  Zurb Foundation 5.0
       5)  Zurb Foundation 4.0
       6)  Simple CSS
 option  Install page-view analytics?
       1)  None
       2)  Google Analytics
       3)  Segment.io
   extras  Set a robots.txt file to ban spiders? (y/n)
   extras  Create a GitHub repository? (y/n)
   extras  Use or create a project-specific rvm gemset? (y/n)

Web Servers

If you plan to deploy to Heroku, select Puma as your production webserver. Puma is recommended by Heroku.

Database

Choose “SQLite” for the easiest setup. If you choose PostgreSQL or MySQL, the databases must be installed and running before you run Rails Composer.

Template Engine

The example applications use the default “ERB” Rails template engine. Optionally, you can use another template engine, such as Haml or Slim. See instructions for Haml and Rails.

Testing

If you are a beginner, select “None.” Select “RSpec with Capybara” if you want tests.

Front-end Framework

If you choose a front-end framework, you’ll get an application layout file, plus navigation and flash messages, styled with a default theme.

Other Choices

Set a robots.txt file to ban spiders if you want to keep your new site out of Google search results.

If you choose to create a GitHub repository, the generator will prompt you for a GitHub username and password.

It is a good idea to use RVM, the Ruby Version Manager, and create a project-specific rvm gemset (not available on Windows). See Installing Rails.

Contributed Applications

Currently, there are no contributed applications available. If you would like to add your favorite starter application to Rails Composer, open an issue to let us know.

Build Your Own Application

If you choose “Custom application,” you will get a wide set of choices. Not all are actively supported.

A large community of developers contributes code that supports additional gems and favorite configurations offered with the “build your own options.” However, not all contributions are actively maintained. That means not all options are tested or fully supported, so you may need to spend time debugging a “build your own application.”

When you choose “Custom application,” you will see something similar to this:

option  Build a starter application?
      1)  Build a RailsApps example application
      2)  Contributed applications
      3)  Custom application

option  Web server for development?
      1)  WEBrick (default)
      2)  Thin
      3)  Unicorn
      4)  Puma
      5)  Phusion Passenger (Apache/Nginx)
      6)  Phusion Passenger (Standalone)

option  Web server for production?
      1)  Same as development
      2)  Thin
      3)  Unicorn
      4)  Puma
      5)  Phusion Passenger (Apache/Nginx)
      6)  Phusion Passenger (Standalone)

option  Database used in development?
      1)  SQLite
      2)  PostgreSQL
      3)  MySQL

option  Template engine?
      1)  ERB
      2)  Haml
      3)  Slim

option  Test framework?
      1)  None
      2)  RSpec with Capybara

option  Continuous testing?
      1)  None
      2)  Guard

option  Front-end framework?
      1)  None
      2)  Bootstrap 3.0
      3)  Bootstrap 2.3
      4)  Zurb Foundation 5.0
      5)  Zurb Foundation 4.0
      6)  Simple CSS

option  Add support for sending email?
      1)  None
      2)  Gmail
      3)  SMTP
      4)  SendGrid
      5)  Mandrill

option  Authentication?
      1)  None
      2)  Devise
      3)  OmniAuth

option  Devise modules?
      1)  Devise with default modules
      2)  Devise with Confirmable module

option  Authorization?
      1)  None
      2)  Pundit

option  Use a form builder gem?
      1)  None
      2)  SimpleForm

option  Install a starter app?
      1)  None
      2)  Home Page
      3)  Home Page, User Accounts
      4)  Home Page, User Accounts, Admin Dashboard

extras  Add 'therubyracer' JavaScript runtime (for Linux users without node.js)? (y/n)
extras  Set a robots.txt file to ban spiders? (y/n)
extras  Create a GitHub repository? (y/n)

option  Add gem and file for environment variables?
      1)  None
      2)  Add .env with Foreman
      3)  Add application.yml with Figaro

extras  Reduce assets logger noise during development? (y/n)
extras  Improve error reporting with 'better_errors' during development? (y/n)
extras  Use 'pry' as console replacement during development and test? (y/n)
extras  Use or create a project-specific rvm gemset? (y/n)

option  Add a deployment mechanism?
      1)  None
      2)  Capistrano3

Run the Application

Switch to the application directory to examine and test what you’ve built.

$ cd myapp

Quick Test

For a “smoke test” to see if everything runs, display a list of Rake tasks.

$ rake -T

There’s no need to run bundle exec rake instead of rake when you are using rvm (see rvm and bundler integration).

Start the Web Server

If you’ve chosen WEBrick or Thin for your web server, can run the app by entering the command:

$ rails server

To see your application in action, open a browser window and navigate to http://localhost:3000/.

For the Unicorn web server:

$ unicorn

See the app at http://localhost:8080/.

For the Puma web server:

$ rails server puma

See the app at http://localhost:3000/.

For Phusion Passenger (Apache or Nginx integration mode), please refer to the official documentation.

For Phusion Passenger (Standalone):

$ passenger start

Login

If you’ve created a version of the application that sets up a default user, log in with:

You should delete or change any pre-configured logins before you deploy your application.

Testing

Some versions of the starter application will contain a suite of RSpec feature and unit tests.

Run rspec to run all RSpec tests.

Please send the author a message, create an issue, or submit a pull request if you want to contribute improved RSpec tests.

Deployment

For easy deployment, use a “platform as a service” provider such as:

For deployment on Heroku, see the article:

Troubleshooting

Problems? Please check both issues for the Rails Composer tool and the issues for the rails_apps_composer gem.

You should review the article Installing Rails to make sure you’ve updated all the components that are required to run Rails successfully.

Problems with “Could not be loaded… You have already activated…”

If you get an error like this:

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
    composer  Running 'after bundler' callbacks.
The template [...] could not be loaded.
Error: You have already activated ..., but your Gemfile requires ....
Using bundle exec may solve this.

It’s due to conflicting gem versions. See the article Rails Error: “You have already activated (…)”.

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.

Problems with “Segmentation Fault”

If you get a “segfault” when you try rails new, try removing and reinstalling rvm.

Application Template Default

The rails new command creates a new Rails application. If you want to use the Rails Composer application 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 template when you create a new Rails application:

# ~/.railsrc
-m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

Documentation and Support

The Rails Composer application template is assembled from recipes supplied by the rails_apps_composer gem. See the rails_apps_composer project to understand how the Rails Composer application works.

Customizing the Template

If you wish to change the template to generate an 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. A big thanks to Yehuda Katz for creating Thor.

About Rails Application Templates

There is an unfinished Rails Guide on Rails Application Templates.

Also see:

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:

Issues

Problems? Please check both issues for the Rails Composer tool and the issues for the rails_apps_composer gem.

Where to Get Help

Your best source for help with problems is Stack Overflow. Your issue may have been encountered and addressed by others.

Use the tag “railsapps” on Stack Overflow for extra attention.

Contributing

Please make changes to the rails_apps_composer gem rather than changing the Rails Composer application template.

Credits

Daniel Kehoe initiated the RailsApps project. The rails_apps_composer gem is derived from Michael Bleigh’s RailsWizard gem.

Is it 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.

License

MIT License

Copyright 2012-14 Daniel Kehoe

Useful Links

Getting Started Articles Tutorials
Ruby on Rails Analytics for Rails Rails Bootstrap
What is Ruby on Rails? Heroku and Rails Rails Foundation
Learn Ruby on Rails JavaScript and Rails RSpec Tutorial
Rails Tutorial Rails Environment Variables Rails Devise Tutorial
Ruby on Rails Tutorial for Beginners Git and GitHub with Rails Devise RSpec
Install Ruby on Rails Send Email with Rails Devise Bootstrap
Install Ruby on Rails – Mac OS X Haml and Rails Rails Membership Site with Stripe
Install Ruby on Rails – Ubuntu Rails Application Layout Rails Subscription Site with Recurly
Ruby on Rails – Nitrous.io HTML5 Boilerplate for Rails Startup Prelaunch Signup Application
Update Rails Example Gemfiles for Rails
Rails Composer Rails Application Templates
Rails Examples Rails Product Planning
Rails Starter Apps Rails Project Management

More Repositories

1

rails_apps_composer

A gem with recipes to create Rails application templates for Rails starter apps.
Ruby
1,423
star
2

rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.
Ruby
1,135
star
3

rails3-application-templates

Deprecated (no longer maintained). Use the Rails Composer tool instead.
Ruby
574
star
4

rails_layout

Generates Rails application layout files for various front-end frameworks.
HTML
569
star
5

rails-bootstrap

Rails 5.1 starter app with the Bootstrap 4 front-end framework.
Ruby
523
star
6

rails-devise

Rails 5.0 starter app with Devise for authentication.
Ruby
513
star
7

rails3-bootstrap-devise-cancan

Outdated. See the rails-devise-pundit example app for Rails 4.1.
Ruby
491
star
8

rails-devise-pundit

Rails 5.0 starter app with Devise for authentication and Pundit for authorization.
Ruby
486
star
9

rails3-devise-rspec-cucumber

An example Rails 3.2 app with Devise and RSpec and Cucumber.
Ruby
446
star
10

rails-prelaunch-signup

An example Rails 3.2 app for a web startup prelaunch site.
Ruby
445
star
11

rails3-mongoid-devise

An example Rails 3.2 app with Mongoid for data, Devise for authentication.
Ruby
402
star
12

learn-rails

An example Rails 5.1 app to accompany the "Learn Ruby on Rails" book.
Ruby
391
star
13

rails3-mongoid-omniauth

An example Rails 3.2 app with Mongoid for data, OmniAuth for authentication. With a tutorial.
Ruby
286
star
14

rails-omniauth

Rails 5.0 starter app with OmniAuth for authentication.
Ruby
278
star
15

rails3-subdomains

An example Rails 3.2 app with subdomains and authentication using Devise. With a tutorial.
Ruby
272
star
16

rails-devise-roles

Rails 5.0 starter app with Devise and simple role-based authorization.
Ruby
186
star
17

rails-recurly-subscription-saas

An example Rails 3.2 app with recurring billing using Recurly for a membership or subscription site.
Ruby
174
star
18

rails-stripe-checkout

Rails 5.0 starter app for selling a product using Stripe Checkout
Ruby
99
star
19

rails_apps_testing

Set up a testing framework for a Rails application.
Ruby
98
star
20

rails-foundation

Rails 4.2 starter app with the Zurb Foundation front-end framework.
Ruby
53
star
21

rails-stripe-coupons

Rails 5.0 starter app for selling a product using Stripe JS
Ruby
49
star
22

rails-signup-download

Rails 5.0 starter app allows a visitor to sign up for an account and download a PDF file.
Ruby
42
star
23

rails-mailinglist-activejob

Rails 5.0 starter app using Active Job for background processing.
Ruby
36
star
24

rails_apps_pages

Add pages to a Rails application, including controllers, views, routing, and tests.
HTML
23
star
25

rails-challenges

Slideshow about the difficulties faced by Rails beginners.
11
star
26

rails-signup-thankyou

Rails 5.2 example application with signup, download, and thank you page.
Ruby
11
star
27

railsapps.github.com

Content for the RailsApps website.
HTML
10
star
28

mailinglist.railscomposer.com

Mailing list signup application for Rails Composer.
Ruby
2
star
29

talk-what-is-ror

Slideshow for a talk, "What is Ruby on Rails."
2
star
30

railsapps-org

Website for the RailsApps open source project.
HTML
1
star