From 940552ef42e1761fa3a6502d388f533a952ffe54 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 11 Jun 2011 22:11:16 +0530 Subject: make some changes to the command line guide --- railties/guides/source/command_line.textile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 026c15feba..8de7101030 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -51,7 +51,7 @@ $ rails new commandsapp Rails will set you up with what seems like a huge amount of stuff for such a tiny command! You've got the entire Rails directory structure now with all the code you need to run our simple application right out of the box. -INFO: This output will seem very familiar when we get to the +generate+ command. Creepy foreshadowing! +INFO: This output will seem very familiar when we get to the +generate+ command. h4. +rails server+ @@ -288,11 +288,7 @@ You can also use the alias "db" to invoke the dbconsole: rails db. h4. +rails plugin+ -The +rails plugin+ command simplifies plugin management; think a miniature version of the Gem utility. Let's walk through installing a plugin. You can call the sub-command +discover+, which sifts through repositories looking for plugins, or call +source+ to add a specific repository of plugins, or you can specify the plugin location directly. - -Let's say you're creating a website for a client who wants a small accounting system. Every event having to do with money must be logged, and must never be deleted. Wouldn't it be great if we could override the behavior of a model to never actually take its record out of the database, but instead, just set a field? - -There is such a thing! The plugin we're installing is called +acts_as_paranoid+, and it lets models implement a +deleted_at+ column that gets set when you call destroy. Later, when calling find, the plugin will tack on a database check to filter out "deleted" things. +The +rails plugin+ command simplifies plugin management; think a miniature version of the Gem utility. $ rails plugin install https://github.com/technoweenie/acts_as_paranoid.git @@ -310,6 +306,12 @@ h4. +rails runner+ $ rails runner "Model.long_running_method" +You can specify the environment in which the +runner+ command should operate using the +-e+ switch. + + +$ rails runner -e staging "Model.long_running_method" + + h4. +rails destroy+ Think of +destroy+ as the opposite of +generate+. It'll figure out what generate did, and undo it. @@ -388,6 +390,8 @@ h4. +db+ The most common tasks of the +db:+ Rake namespace are +migrate+ and +create+, and it will pay off to try out all of the migration rake tasks (+up+, +down+, +redo+, +reset+). +rake db:version+ is useful when troubleshooting, telling you the current version of the database. +More information about migrations can be found in the "Migrations":migrations.html guide. + h4. +doc+ If you want to strip out or rebuild any of the Rails documentation (including this guide!), the +doc:+ namespace has the tools. Stripping documentation is mainly useful for slimming your codebase, like if you're writing a Rails application for an embedded platform. @@ -478,7 +482,9 @@ development: ... -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 new+ command to generate the basis of your app. +It also generated some lines in our database.yml configuration corresponding to our choice of PostgreSQL for database. + +NOTE. 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 new+ command to generate the basis of your app. h4. +server+ with Different Backends -- cgit v1.2.3 From d91ee6cba43b474df47751c130da781f9febeb90 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 12 Jun 2011 01:30:40 +0530 Subject: more command guide changes --- railties/guides/source/command_line.textile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 8de7101030..013476a4dd 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -51,15 +51,13 @@ $ rails new commandsapp Rails will set you up with what seems like a huge amount of stuff for such a tiny command! You've got the entire Rails directory structure now with all the code you need to run our simple application right out of the box. -INFO: This output will seem very familiar when we get to the +generate+ command. - h4. +rails server+ -The +rails server+ command launches a small web server named WEBrick which comes bundled with Ruby. You'll use this any time you want to view your work through a web browser. +The +rails server+ command launches a small web server named WEBrick which comes bundled with Ruby. You'll use this any time you want to access your application through a web browser. -INFO: WEBrick isn't your only option for serving Rails. We'll get to that in a later section. +INFO: WEBrick isn't your only option for serving Rails. We'll get to that "later":#different-servers. -Without any prodding of any kind, +rails server+ will run our new shiny Rails app: +With no further work, +rails server+ will run our new shiny Rails app: $ cd commandsapp @@ -83,7 +81,7 @@ The +rails generate+ command uses templates to create a whole lot of things. You $ rails generate -Usage: rails generate generator [args] [options] +Usage: rails generate GENERATOR [args] [options] ... ... @@ -171,7 +169,7 @@ Then the view, to display our message (in +app/views/greetings/hello.html.erb+):

<%= @message %>

-Deal. Go check it out in your browser. Fire up your server using +rails server+. +Fire up your server using +rails server+. $ rails server @@ -486,7 +484,7 @@ It also generated some lines in our database.yml configuration corresponding to NOTE. 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 new+ command to generate the basis of your app. -h4. +server+ with Different Backends +h4(#different-servers). +server+ with Different Backends Many people have created a large number different web servers in Ruby, and many of them can be used to run Rails. Since version 2.3, Rails uses Rack to serve its webpages, which means that any webserver that implements a Rack handler can be used. This includes WEBrick, Mongrel, Thin, and Phusion Passenger (to name a few!). -- cgit v1.2.3 From 07bf60864474ba2217636ca1d2216fe7b89a6628 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 12 Jun 2011 02:16:08 +0530 Subject: document server options --- railties/guides/source/command_line.textile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 013476a4dd..57c71eee09 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -75,6 +75,12 @@ With just three commands we whipped up a Rails server listening on port 3000. Go You can also use the alias "s" to start the server: rails s. +The server can be run on a different port using the +-p+ option. The default development environment can be changed using +-e+. + + +$ rails server -e production + + h4. +rails generate+ The +rails generate+ command uses templates to create a whole lot of things. You can always find out what's available by running +rails generate+ by itself. Let's do that: -- cgit v1.2.3 From d48bbc895f08efd9b98e79986d1e9aeb43c1baef Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Sat, 11 Jun 2011 19:32:01 -0300 Subject: Add example for rails server port option. --- railties/guides/source/command_line.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 57c71eee09..6110846b19 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -78,7 +78,7 @@ You can also use the alias "s" to start the server: rails s. The server can be run on a different port using the +-p+ option. The default development environment can be changed using +-e+. -$ rails server -e production +$ rails server -e production -p 4000 h4. +rails generate+ -- cgit v1.2.3 From 3e441596509bbb5eb485c60efe78a629c028562e Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 15 Jun 2011 22:53:26 +0530 Subject: document how rake notes work --- railties/guides/source/command_line.textile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 6110846b19..c71baa76d1 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -402,7 +402,28 @@ If you want to strip out or rebuild any of the Rails documentation (including th h4. +notes+ -These tasks will search through your code for commented lines beginning with "FIXME", "OPTIMIZE", "TODO", or any custom annotation (like XXX) and show you them. ++rake notes+ will search through your code for comments beginning with FIXME, OPTIMIZE or TODO. This checks only for files with extension +.builder+, +.rb+, +.rxml+, +.rhtml+ and +.erb+. + + +$ rake notes +(in /home/foobar/commandsapp) +app/controllers/admin/users_controller.rb: + * [ 20] [TODO] any other way to do this? + * [132] [FIXME] high priority for next deploy + +app/model/school.rb: + * [ 13] [OPTIMIZE] refactor this code to make it faster + * [ 17] [FIXME] + + +You can also use custom annotations in your code and list them using +rake notes:custom+ and specify the annotation using an environment variable +ANNOTATION+. + + +$ rake notes:custom ANNOTATION=BUG +(in /home/foobar/commandsapp) +app/model/post.rb: + * [ 23] Have to fix this one before pushing! + h4. +routes+ -- cgit v1.2.3 From 406d61ee8c0311f742ac74b9a15845cc3cd214d3 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 15 Jun 2011 23:26:19 +0530 Subject: add details on how to use specific annotations in rake:notes --- railties/guides/source/command_line.textile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index c71baa76d1..03ff3097da 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -402,7 +402,7 @@ If you want to strip out or rebuild any of the Rails documentation (including th h4. +notes+ -+rake notes+ will search through your code for comments beginning with FIXME, OPTIMIZE or TODO. This checks only for files with extension +.builder+, +.rb+, +.rxml+, +.rhtml+ and +.erb+. ++rake notes+ will search through your code for comments beginning with FIXME, OPTIMIZE or TODO. The search is only done in files with extension +.builder+, +.rb+, +.rxml+, +.rhtml+ and +.erb+ for both default and custom annotations. $ rake notes @@ -416,7 +416,19 @@ app/model/school.rb: * [ 17] [FIXME] -You can also use custom annotations in your code and list them using +rake notes:custom+ and specify the annotation using an environment variable +ANNOTATION+. +If you are looking for a specific annotation, say FIXME, you can use +rake notes:fixme+. Note that you have to lower case the annotation's name. + + +$ rake notes:fixme +(in /home/foobar/commandsapp) +app/controllers/admin/users_controller.rb: + * [132] high priority for next deploy + +app/model/school.rb: + * [ 17] + + +You can also use custom annotations in your code and list them using +rake notes:custom+ by specifying the annotation using an environment variable +ANNOTATION+. $ rake notes:custom ANNOTATION=BUG @@ -425,6 +437,8 @@ app/model/post.rb: * [ 23] Have to fix this one before pushing! +NOTE. When using specific annotations and custom annotations, the annotation name (FIXME, BUG etc) is not displayed in the output lines. + h4. +routes+ +rake routes+ will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with. -- cgit v1.2.3 From 0dd9db871d78408db7b1fe7397c3fcf7c9ffb541 Mon Sep 17 00:00:00 2001 From: JudeAr Date: Wed, 15 Jun 2011 22:04:20 -0700 Subject: fixed typo chnages --- railties/guides/source/command_line.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 03ff3097da..bedb9fc6d9 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -527,7 +527,7 @@ NOTE. The only catch with using the SCM options is that you have to make your ap h4(#different-servers). +server+ with Different Backends -Many people have created a large number different web servers in Ruby, and many of them can be used to run Rails. Since version 2.3, Rails uses Rack to serve its webpages, which means that any webserver that implements a Rack handler can be used. This includes WEBrick, Mongrel, Thin, and Phusion Passenger (to name a few!). +Many people have created a large number of different web servers in Ruby, and many of them can be used to run Rails. Since version 2.3, Rails uses Rack to serve its webpages, which means that any webserver that implements a Rack handler can be used. This includes WEBrick, Mongrel, Thin, and Phusion Passenger (to name a few!). NOTE: For more details on the Rack integration, see "Rails on Rack":rails_on_rack.html. -- cgit v1.2.3 From cbf2af1e81fcae8c0ee4472e7bb0620c77786106 Mon Sep 17 00:00:00 2001 From: JudeAr Date: Wed, 15 Jun 2011 22:15:53 -0700 Subject: typo changes fixed --- railties/guides/source/command_line.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index bedb9fc6d9..8c78cab84f 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -3,7 +3,7 @@ h2. A Guide to The Rails Command Line Rails comes with every command line tool you'll need to * Create a Rails application -* Generate models, controllers, database migrations, and unit tests +* Generate models, controllers, database migrations and unit tests * Start a development server * Experiment with objects through an interactive shell * Profile and benchmark your new creation -- cgit v1.2.3 From bfb022adae4b8f6ba35872531bc5774b72fbe467 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 16 Jun 2011 12:29:47 +0530 Subject: document doc:* rake tasks --- railties/guides/source/command_line.textile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 8c78cab84f..b42fdac7e4 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -398,7 +398,13 @@ More information about migrations can be found in the "Migrations":migrations.ht h4. +doc+ -If you want to strip out or rebuild any of the Rails documentation (including this guide!), the +doc:+ namespace has the tools. Stripping documentation is mainly useful for slimming your codebase, like if you're writing a Rails application for an embedded platform. +The +doc:+ namespace has the tools to generate documentation for your app, API documentation, guides. Documentation can also be stripped which is mainly useful for slimming your codebase, like if you're writing a Rails application for an embedded platform. + +* +rake doc:app+ generates documentation for your application in +doc/app+. +* +rake doc:guides+ generates Rails guides in +doc/guides+. +* +rake doc:rails+ generates API documentation for Rails in +doc/api+. +* +rake doc:plugins+ generates API documentation for all the plugins installed in the application in +doc/plugins+. +* +rake doc:clobber_plugins+ removes the generated documentation for all plugins. h4. +notes+ -- cgit v1.2.3 From 7c2db6ce37aa37014ad216e0f5070c6b147382e7 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 16 Jun 2011 22:48:47 +0530 Subject: add info that plugin installs need git or svn installed --- railties/guides/source/command_line.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index b42fdac7e4..dd21fb0e93 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -292,7 +292,7 @@ You can also use the alias "db" to invoke the dbconsole: rails db. h4. +rails plugin+ -The +rails plugin+ command simplifies plugin management; think a miniature version of the Gem utility. +The +rails plugin+ command simplifies plugin management. Plugins can be installed by name or their repository urls. You need to have git installed if you want to install a plugin from a git repo. The same holds for Subversion too. $ rails plugin install https://github.com/technoweenie/acts_as_paranoid.git -- cgit v1.2.3 From 07d62ff7191f3334dffece1495a38b35f5669cbf Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 16 Jun 2011 22:48:05 +0530 Subject: minor clean up generators section --- railties/guides/source/command_line.textile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'railties/guides/source/command_line.textile') diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index dd21fb0e93..43f2aad5bf 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -83,7 +83,7 @@ $ rails server -e production -p 4000 h4. +rails generate+ -The +rails generate+ command uses templates to create a whole lot of things. You can always find out what's available by running +rails generate+ by itself. Let's do that: +The +rails generate+ command uses templates to create a whole lot of things. Running +rails generate+ by itself gives a list of available generators: $ rails generate @@ -103,7 +103,7 @@ Rails: NOTE: You can install more generators through generator gems, portions of plugins you'll undoubtedly install, and you can even create your own! -Using generators will save you a large amount of time by writing *boilerplate code*, code that is necessary for the app to work, but not necessary for you to spend time writing. That's what we have computers for. +Using generators will save you a large amount of time by writing *boilerplate code*, code that is necessary for the app to work. Let's make our own controller with the controller generator. But what command should we use? Let's ask the generator: @@ -152,7 +152,8 @@ $ rails generate controller Greetings hello create test/unit/helpers/greetings_helper_test.rb invoke assets create app/assets/javascripts/greetings.js - create app/assets/stylesheets/greetings.css + invoke css + create app/assets/stylesheets/greetings.css @@ -188,7 +189,7 @@ The URL will be "http://localhost:3000/greetings/hello":http://localhost:3000/gr INFO: With a normal, plain-old Rails application, your URLs will generally follow the pattern of http://(host)/(controller)/(action), and a URL like http://(host)/(controller) will hit the *index* action of that controller. -Rails comes with a generator for data models too: +Rails comes with a generator for data models too. $ rails generate model -- cgit v1.2.3