1.4. Rails Commands and Configuration

Once Rails is installed, the rails command can be used to generate new Rails applications with a default directory structure and configuration at the path you specify.

To create a Rails application called myapp, type:

rails myapp

Once this is run, you will see a list of directories and files displayed that were generated by the command. This is your Rails application, with myapp being the base folder, or RAILS ROOT.

1.4.1. Usage and Options

For help with the rails command, type:

rails --help Usage
rails [/path/to/your/appname] [options] Options

-r, --ruby=path

Path to the Ruby binary of your choice

-d, --database=name

Preconfigured for a selected database (e.g., mysql, oracle, postgresql, sqlite2, sqlite3)

-f, --freeze

Freezes Rails in vendor/rails from the gems generating the skeleton

-v, --version

Shows the Rails version number and quits

-p, --pretend

Runs but does not make any changes


Overwrites files that already exist

-s, --skip

Skips files that already exist

-q, --quiet

Suppresses normal output

-t, --backtrace

Debugging; shows backtrace on errors

-c, --svn

Modifies files with subversion (svn must be in path)

1.4.2. Rails File Structure

After generating a Rails application, a default directory and file structure is created. See Table 1-1.

Table 1-1. Rails file structure
appHolds all the code that’s specific to this particular application.
app/controllersHolds controllers that should be named like users_controller.rb for automated ...

Get Rails Pocket Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.