Rails Composer。针对初级应用程序的强大 Rails 生成器。
$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rbReplace @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. h3. Creating a Starter App Using RVM I recommend using "RVM":https://rvm.io/, the Ruby Version Manager, to manage your Rails versions, as described in the "Installing Rails":http://railsapps.github.io/installing-rails.html 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.rbInstead 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. h2. Choose a RailsApps Starter Application Use Rails Composer to generate any of the example applications from the "RailsApps project":http://railsapps.github.io/. 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":https://github.com/RailsApps and each is accompanied by a tutorial on the "Capstone Rails Tutorials":https://tutorials.railsapps.org/ site.
Make your choice. The Rails Composer tool may give you other options (other applications may have been added since these notes were written).
h4. 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)
h4. Web Servers
If you plan to deploy to Heroku, select Puma as your production webserver. Puma is recommended by Heroku.
h4. 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.
h4. 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":http://railsapps.github.io/rails-haml.html.
h4. Testing
If you are a beginner, select "None." Select "RSpec with Capybara" if you want tests.
h4. 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.
h4. 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":https://rvm.io/, the Ruby Version Manager, and create a project-specific rvm gemset (not available on Windows). See "Installing Rails":http://railsapps.github.io/installing-rails.html.
h2. 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.
h2. 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[Feature request] Support for Rails 6.0.0
"File unchanged! The supplied flag value not found!" error on creation of starter app
Enhancement: even margins
Vulnerable version of bootstrap 4 provided
Rails 5.2.0 - Ruby 2.5.1 - composer fails when composing mysql at higher version
Crashes when installing gems, `apply': uninitialized constant Rails::Generators::AppGenerator::RVM (NameError)
postgres socket connection without password not working
Petergate: Easy Authorization library.
ripgrep complains about errors in .gitignore
Sass is breaking on @extend “.bg-faded”