diff options
author | Colin Curtin <colin@procore.com> | 2009-02-02 00:23:36 -0800 |
---|---|---|
committer | Colin Curtin <colin@procore.com> | 2009-02-02 00:23:36 -0800 |
commit | b29972d1bf762cc3660f199cb09ada7f22ce231a (patch) | |
tree | 78ef6e3ab1429963977bd59a1ee677b4c8e3511e /railties | |
parent | 1ae0726ade841d761b63ce8e7de4e2d9adf8b689 (diff) | |
download | rails-b29972d1bf762cc3660f199cb09ada7f22ce231a.tar.gz rails-b29972d1bf762cc3660f199cb09ada7f22ce231a.tar.bz2 rails-b29972d1bf762cc3660f199cb09ada7f22ce231a.zip |
Added the first part to the Rails Advanced Command Line
Diffstat (limited to 'railties')
-rw-r--r-- | railties/doc/guides/source/command_line.txt | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/railties/doc/guides/source/command_line.txt b/railties/doc/guides/source/command_line.txt index 8a887bd001..4f1dd49f35 100644 --- a/railties/doc/guides/source/command_line.txt +++ b/railties/doc/guides/source/command_line.txt @@ -56,7 +56,7 @@ Let's try it! The `server` command launches a small web server named WEBrick whi NOTE: WEBrick isn't your only option for serving Rails. We'll get to that in a later section. [XXX: which section] -Here we'll flex our `server` command, which without any prodding of any kind will run our new shiny Rails app: +Without any prodding of any kind, `server` will run our new shiny Rails app: [source,shell] ------------------------------------------------------ @@ -318,7 +318,7 @@ $ ./script/destroy model Oops ------------------------------------------------------ === about === -Check it: Version numbers for Ruby, RubyGems, Rails, the Rails subcomponents, your application's folder, the current Rails environment name, your app's database adapter, and schema version! `about` is useful when you need to ask help, check if a security patch might affect you, or when you need some stats for an existing Rails installation. +Check it: Version numbers for Ruby, RubyGems, Rails, the Rails subcomponents, your application's folder, the current Rails environment name, your app's database adapter, and schema version! `about` is useful when you need to ask for help, check if a security patch might affect you, or when you need some stats for an existing Rails installation. [source,shell] ------------------------------------------------------ @@ -337,4 +337,66 @@ Application root /home/commandsapp Environment development Database adapter sqlite3 Database schema version 20081217073400 -------------------------------------------------------
\ No newline at end of file +------------------------------------------------------ + +== The Rails Advanced Command Line (RACL!) == +The more advanced uses of the command line are focused around finding useful (even surprising at times) options in the utilities, and fitting utilities to your needs and specific work flow. Listed here are some tricks up Rails' sleeve. + +=== rails with databases and SCM === +When creating a new Rails application, you have the option to specify what kind of database and what kind of source code management system your application is going to use. This will save you a few minutes, and certainly many keystrokes. + +Let's see what a `--git` option and a `--database=postgresql` option will do for us: + +[source,shell] +------------------------------------------------------ +$ mkdir gitapp +$ cd gitapp +$ git init +Initialized empty Git repository in .git/ +$ rails . --git --database=postgresql + exists + create app/controllers + create app/helpers +... +... + create tmp/cache + create tmp/pids + create Rakefile +add 'Rakefile' + create README +add 'README' + create app/controllers/application.rb +add 'app/controllers/application.rb' + create app/helpers/application_helper.rb +... + create log/test.log +add 'log/test.log' +------------------------------------------------------ + +We had to create the *gitapp* directory and initialize an empty git repository before Rails would add files it created to our repository. Let's see what it put in our database configuration: + +[source,shell] +------------------------------------------------------ +$ cat config/database.yml +# PostgreSQL. Versions 7.4 and 8.x are supported. +# +# Install the ruby-postgres driver: +# gem install ruby-postgres +# On Mac OS X: +# gem install ruby-postgres -- --include=/usr/local/pgsql +# On Windows: +# gem install ruby-postgres +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +development: + adapter: postgresql + encoding: unicode + database: gitapp_development + pool: 5 + username: gitapp + password: +... +... +------------------------------------------------------ + +It also generated some lines in our database.yml configuration corresponding to our choice of PostgreSQL for database. The only catch with using the SCM options is that you have to make your application's directory first, then initialize your SCM, then you can run the `rails` command to generate the basis of your app.
\ No newline at end of file |