Permalink
Browse files

fix usage examples and more to use new invocations

Signed-off-by: Carl Lerche <carllerche@mac.com>
  • Loading branch information...
1 parent 6958eac commit f44a0b1d524064a2e919cd10d3013db680af9b17 @romdi romdi committed with Carl Lerche Feb 6, 2010
Showing with 173 additions and 173 deletions.
  1. +1 −1 actionmailer/README
  2. +1 −1 actionmailer/lib/action_mailer/base.rb
  3. +2 −2 activerecord/lib/active_record/migration.rb
  4. +1 −1 activesupport/lib/active_support/core_ext/kernel/debugger.rb
  5. +1 −1 activesupport/lib/active_support/whiny_nil.rb
  6. +9 −9 railties/README
  7. +3 −3 railties/guides/source/3_0_release_notes.textile
  8. +3 −3 railties/guides/source/action_mailer_basics.textile
  9. +1 −1 railties/guides/source/active_support_core_extensions.textile
  10. +1 −1 railties/guides/source/activerecord_validations_callbacks.textile
  11. +29 −29 railties/guides/source/command_line.textile
  12. +6 −6 railties/guides/source/debugging_rails_applications.textile
  13. +14 −14 railties/guides/source/generators.textile
  14. +13 −13 railties/guides/source/getting_started.textile
  15. +5 −5 railties/guides/source/migrations.textile
  16. +8 −8 railties/guides/source/performance_testing.textile
  17. +14 −14 railties/guides/source/plugins.textile
  18. +5 −5 railties/guides/source/rails_on_rack.textile
  19. +4 −4 railties/guides/source/testing.textile
  20. +8 −8 railties/lib/generators/rails/app/templates/README
  21. +1 −1 railties/lib/generators/rails/controller/USAGE
  22. +1 −1 railties/lib/generators/rails/generator/USAGE
  23. +1 −1 railties/lib/generators/rails/generator/templates/USAGE.tt
  24. +1 −1 railties/lib/generators/rails/helper/USAGE
  25. +1 −1 railties/lib/generators/rails/integration_test/USAGE
  26. +1 −1 railties/lib/generators/rails/mailer/USAGE
  27. +1 −1 railties/lib/generators/rails/metal/USAGE
  28. +2 −2 railties/lib/generators/rails/migration/USAGE
  29. +2 −2 railties/lib/generators/rails/model/USAGE
  30. +1 −1 railties/lib/generators/rails/observer/USAGE
  31. +1 −1 railties/lib/generators/rails/performance_test/USAGE
  32. +1 −1 railties/lib/generators/rails/plugin/USAGE
  33. +3 −3 railties/lib/generators/rails/resource/USAGE
  34. +4 −4 railties/lib/generators/rails/scaffold/USAGE
  35. +1 −1 railties/lib/generators/rails/scaffold_controller/USAGE
  36. +1 −1 railties/lib/generators/rails/session_migration/USAGE
  37. +1 −1 railties/lib/generators/rails/stylesheets/USAGE
  38. +1 −1 railties/lib/rails/commands/console.rb
  39. +6 −6 railties/lib/rails/commands/plugin.rb
  40. +2 −2 railties/lib/rails/generators/actions.rb
  41. +4 −4 railties/lib/rails/generators/base.rb
  42. +1 −1 railties/lib/rails/rack/debugger.rb
  43. +5 −5 railties/test/generators/actions_test.rb
  44. +1 −1 railties/test/isolation/abstract_unit.rb
View
@@ -101,7 +101,7 @@ Example:
This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
trivial case like this:
- ./script/runner 'Mailman.receive(STDIN.read)'
+ rails runner 'Mailman.receive(STDIN.read)'
However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
instance of Rails should be run within a daemon if it is going to be utilized to process more than just
@@ -9,7 +9,7 @@ module ActionMailer #:nodoc:
#
# To use Action Mailer, you need to create a mailer model.
#
- # $ script/generate mailer Notifier
+ # $ rails generate mailer Notifier
#
# The generated model inherits from ActionMailer::Base. Emails are defined by creating methods
# within the model which are then used to set variables to be used in the mail template, to
@@ -107,7 +107,7 @@ def initialize(name)
# The Rails package has several tools to help create and apply migrations.
#
# To generate a new migration, you can use
- # script/generate migration MyNewMigration
+ # rails generate migration MyNewMigration
#
# where MyNewMigration is the name of your migration. The generator will
# create an empty migration file <tt>timestamp_my_new_migration.rb</tt> in the <tt>db/migrate/</tt>
@@ -117,7 +117,7 @@ def initialize(name)
# MyNewMigration.
#
# There is a special syntactic shortcut to generate migrations that add fields to a table.
- # script/generate migration add_fieldname_to_tablename fieldname:string
+ # rails generate migration add_fieldname_to_tablename fieldname:string
#
# This will generate the file <tt>timestamp_add_fieldname_to_tablename</tt>, which will look like this:
# class AddFieldnameToTablename < ActiveRecord::Migration
@@ -1,6 +1,6 @@
module Kernel
unless respond_to?(:debugger)
- # Starts a debugging session if ruby-debug has been loaded (call script/server --debugger to do load it).
+ # Starts a debugging session if ruby-debug has been loaded (call rails server --debugger to do load it).
def debugger
message = "\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n"
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
@@ -11,7 +11,7 @@
# classes in NilClass::WHINERS the error message suggests which could be the
# actual intended class:
#
-# $ script/runner nil.destroy
+# $ rails runner nil.destroy
# ...
# You might have expected an instance of ActiveRecord::Base.
# ...
View
@@ -29,14 +29,14 @@ link:files/vendor/rails/actionpack/README.html.
1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
and your application name. Ex: <tt>rails myapp</tt>
-2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
+2. Change directory into myapp and start the web server: <tt>rails server</tt> (run with --help for options)
3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
4. Follow the guidelines to start developing your application
== Web Servers
-By default, Rails will try to use Mongrel if it's installed when started with script/server, otherwise
+By default, Rails will try to use Mongrel if it's installed when started with <tt>rails server</tt>, otherwise
Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails with a variety of
other web servers.
@@ -45,7 +45,7 @@ suitable for development and deployment of Rails applications. If you have Ruby
getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
More info at: http://mongrel.rubyforge.org
-Other ruby web servers exist which can run your rails application, however script/server does
+Other ruby web servers exist which can run your rails application, however <tt>rails server</tt> does
not search for them or start them. These include {Thin}[http://code.macournoyer.com/thin/], {Ebb}[http://ebb.rubyforge.org/], and Apache with {mod_rails}[http://www.modrails.com/].
For production use, often a web/proxy server such as {Apache}[http://apache.org], {Nginx}[http://nginx.net/], {LiteSpeed}[http://litespeedtech.com/], {Lighttpd}[http://www.lighttpd.net/] or {IIS}[http://www.iis.net/] is
@@ -168,22 +168,22 @@ model. Here you'll have all parts of the application configured, just like it is
application is running. You can inspect domain models, change values, and save to the
database. Starting the script without arguments will launch it in the development environment.
-To start the console, just run <tt>script/console</tt> from the application directory.
+To start the console, just run <tt>rails console</tt> from the application directory.
Options:
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications made to the database.
* Passing an environment name as an argument will load the corresponding environment.
- Example: <tt>script/console production</tt>.
+ Example: <tt>rails console production</tt>.
More information about irb can be found at link:http://www.rubycentral.com/pickaxe/irb.html
== dbconsole
-You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
+You can go to the command line of your database directly through <tt>rails dbconsole</tt>.
You would be connected to the database with the credentials defined in database.yml.
Starting the script without arguments will connect you to the development database. Passing an
-argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
+argument will connect you to a different database, like <tt>rails dbconsole production</tt>.
Currently works for mysql, postgresql and sqlite.
== Description of Contents
@@ -250,7 +250,7 @@ app/views/layouts
app/helpers
Holds view helpers that should be named like weblogs_helper.rb. These are generated
- for you automatically when using script/generate for controllers. Helpers can be used to
+ for you automatically when using <tt>rails generate</tt> for controllers. Helpers can be used to
wrap functionality for your views into methods.
config
@@ -277,7 +277,7 @@ script
Helper scripts for automation and generation.
test
- Unit and functional tests along with fixtures. When using the script/generate scripts, template
+ Unit and functional tests along with fixtures. When using the <tt>rails generate</tt> scripts, template
test files will be generated for you and placed in this directory.
vendor
@@ -39,8 +39,8 @@ h4. script/* replaced by script/rails
The new <tt>script/rails</tt> replaces all the scripts that used to be in the <tt>script</tt> directory. You do not run <tt>script/rails</tt> directly though, the +rails+ command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is:
<shell>
-rails console # => ./script/console
-rails g scaffold post title:string # => ./script/generate scaffold post title:string
+rails console # => ./script/rails console
+rails g scaffold post title:string # => ./script/rails generate scaffold post title:string
</shell>
Run rails --help for a list of all the options.
@@ -557,4 +557,4 @@ h3. Credits
See the "full list of contributors to Rails":http://contributors.rubyonrails.org/ for the many people who spent many hours making Rails 3. Kudos to all of them.
-Rails 3.0 Release Notes were compiled by "Mikel Lindsaar":http://lindsaar.net.
+Rails 3.0 Release Notes were compiled by "Mikel Lindsaar":http://lindsaar.net.
@@ -19,7 +19,7 @@ h4. Walkthrough to Generating a Mailer
h5. Create the Mailer
<shell>
-./script/generate mailer UserMailer
+rails generate mailer UserMailer
create app/mailers/user_mailer.rb
invoke erb
create app/views/user_mailer
@@ -111,7 +111,7 @@ Let's see how we would go about wiring it up using an observer.
First off, we need to create a simple +User+ scaffold:
<shell>
-$ script/generate scaffold user name:string email:string login:string
+$ rails generate scaffold user name:string email:string login:string
$ rake db:migrate
</shell>
@@ -333,7 +333,7 @@ Receiving and parsing emails with Action Mailer can be a rather complex endeavou
* Implement a +receive+ method in your mailer.
-* Configure your email server to forward emails from the address(es) you would like your app to receive to +/path/to/app/script/runner 'UserMailer.receive(STDIN.read)'+.
+* Configure your email server to forward emails from the address(es) you would like your app to receive to +/path/to/app/script/rails runner 'UserMailer.receive(STDIN.read)'+.
Once a method called +receive+ is defined in any mailer, Action Mailer will parse the raw incoming email into an email object, decode it, instantiate a new mailer, and pass the email object to the mailer +receive+ instance method. Here's an example:
@@ -1805,7 +1805,7 @@ Rails hijacks +LoadError.new+ to return a +MissingSourceFile+ exception:
$ ruby -e 'require "nonexistent"'
...: no such file to load -- nonexistent (LoadError)
...
-$ script/runner 'require "nonexistent"'
+$ rails runner 'require "nonexistent"'
...: no such file to load -- nonexistent (MissingSourceFile)
...
</shell>
@@ -44,7 +44,7 @@ class Person < ActiveRecord::Base
end
</ruby>
-We can see how it works by looking at some script/console output:
+We can see how it works by looking at some +rails console+ output:
<shell>
>> p = Person.new(:name => "John Doe")
@@ -58,7 +58,7 @@ Without any prodding of any kind, +server+ will run our new shiny Rails app:
<shell>
$ cd commandsapp
-$ ./script/server
+$ rails server
=> Booting WEBrick...
=> Rails 2.2.0 application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
@@ -76,8 +76,8 @@ h4. +generate+
The +generate+ command uses templates to create a whole lot of things. You can always find out what's available by running +generate+ by itself. Let's do that:
<shell>
-$ ./script/generate
-Usage: ./script/generate generator [options] [args]
+$ rails generate
+Usage: rails generate generator [options] [args]
...
...
@@ -95,17 +95,17 @@ Using generators will save you a large amount of time by writing *boilerplate co
Let's make our own controller with the controller generator. But what command should we use? Let's ask the generator:
-INFO: All Rails console utilities have help text. As with most *NIX utilities, you can try adding +--help+ or +-h+ to the end, for example +./script/server --help+.
+INFO: All Rails console utilities have help text. As with most *NIX utilities, you can try adding +--help+ or +-h+ to the end, for example +rails server --help+.
<shell>
-$ ./script/generate controller
-Usage: ./script/generate controller ControllerName [options]
+$ rails generate controller
+Usage: rails generate controller ControllerName [options]
...
...
Example:
- ./script/generate controller CreditCard open debit credit close
+ rails generate controller CreditCard open debit credit close
Credit card controller with URLs like /credit_card/debit.
Controller: app/controllers/credit_card_controller.rb
@@ -114,7 +114,7 @@ Example:
Test: test/functional/credit_card_controller_test.rb
Modules Example:
- ./script/generate controller 'admin/credit_card' suspend late_fee
+ rails generate controller 'admin/credit_card' suspend late_fee
Credit card admin controller with URLs /admin/credit_card/suspend.
Controller: app/controllers/admin/credit_card_controller.rb
@@ -126,7 +126,7 @@ Modules Example:
Ah, the controller generator is expecting parameters in the form of +generate controller ControllerName action1 action2+. Let's make a +Greetings+ controller with an action of *hello*, which will say something nice to us.
<shell>
-$ ./script/generate controller Greetings hello
+$ rails generate controller Greetings hello
exists app/controllers/
exists app/helpers/
create app/views/greetings
@@ -157,10 +157,10 @@ Then the view, to display our nice message (in +app/views/greetings/hello.html.e
<p><%= @message %></p>
</html>
-Deal. Go check it out in your browser. Fire up your server. Remember? +./script/server+ at the root of your Rails application should do it.
+Deal. Go check it out in your browser. Fire up your server. Remember? +rails server+ at the root of your Rails application should do it.
<shell>
-$ ./script/server
+$ rails server
=> Booting WEBrick...
</shell>
@@ -173,21 +173,21 @@ INFO: With a normal, plain-old Rails application, your URLs will generally follo
"What about data, though?", you ask over a cup of coffee. Rails comes with a generator for data models too. Can you guess its generator name?
<shell>
-$ ./script/generate model
-Usage: ./script/generate model ModelName [field:type, field:type]
+$ rails generate model
+Usage: rails generate model ModelName [field:type, field:type]
...
Examples:
- ./script/generate model account
+ rails generate model account
creates an Account model, test, fixture, and migration:
Model: app/models/account.rb
Test: test/unit/account_test.rb
Fixtures: test/fixtures/accounts.yml
Migration: db/migrate/XXX_add_accounts.rb
- ./script/generate model post title:string body:text published:boolean
+ rails generate model post title:string body:text published:boolean
creates a Post model with a string title, text body, and published flag.
</shell>
@@ -197,7 +197,7 @@ But instead of generating a model directly (which we'll be doing later), let's s
Let's set up a simple resource called "HighScore" that will keep track of our highest score on video games we play.
<shell>
-$ ./script/generate scaffold HighScore game:string score:integer
+$ rails generate scaffold HighScore game:string score:integer
exists app/models/
exists app/controllers/
exists app/helpers/
@@ -244,13 +244,13 @@ $ rake db:migrate
INFO: Let's talk about unit tests. Unit tests are code that tests and makes assertions about code. In unit testing, we take a little part of code, say a method of a model, and test its inputs and outputs. Unit tests are your friend. The sooner you make peace with the fact that your quality of life will drastically increase when you unit test your code, the better. Seriously. We'll make one in a moment.
-Let's see the interface Rails created for us. ./script/server; http://localhost:3000/high_scores
+Let's see the interface Rails created for us. rails server; http://localhost:3000/high_scores
We can create new high scores (55,160 on Space Invaders!)
h4. +console+
-The +console+ command lets you interact with your Rails application from the command line. On the underside, +script/console+ uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.
+The +console+ command lets you interact with your Rails application from the command line. On the underside, +rails console+ uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.
h4. +dbconsole+
@@ -265,7 +265,7 @@ Let's say you're creating a website for a client who wants a small accounting sy
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.
<shell>
-$ ./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid
+$ rails plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid
+ ./CHANGELOG
+ ./MIT-LICENSE
...
@@ -277,15 +277,15 @@ h4. +runner+
<tt>runner</tt> runs Ruby code in the context of Rails non-interactively. For instance:
<shell>
-$ ./script/runner "Model.long_running_method"
+$ rails runner "Model.long_running_method"
</shell>
h4. +destroy+
Think of +destroy+ as the opposite of +generate+. It'll figure out what generate did, and undo it. Believe you-me, the creation of this tutorial used this command many times!
<shell>
-$ ./script/generate model Oops
+$ rails generate model Oops
exists app/models/
exists test/unit/
exists test/fixtures/
@@ -294,7 +294,7 @@ $ ./script/generate model Oops
create test/fixtures/oops.yml
exists db/migrate
create db/migrate/20081221040817_create_oops.rb
-$ ./script/destroy model Oops
+$ rails destroy model Oops
notempty db/migrate
notempty db
rm db/migrate/20081221040817_create_oops.rb
@@ -314,7 +314,7 @@ h4. +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 for help, check if a security patch might affect you, or when you need some stats for an existing Rails installation.
<shell>
-$ ./script/about
+$ rails about
About your application's environment
Ruby version 1.8.6 (i486-linux)
RubyGems version 1.3.1
@@ -399,7 +399,7 @@ Many people have created a large number different web servers in Ruby, and many
NOTE: For more details on the Rack integration, see "Rails on Rack":rails_on_rack.html.
-To use a different server, just install its gem, then use its name for the first parameter to +script/server+:
+To use a different server, just install its gem, then use its name for the first parameter to +rails server+:
<shell>
$ sudo gem install mongrel
@@ -412,9 +412,9 @@ Successfully installed mongrel-1.1.5
...
...
Installing RDoc documentation for mongrel-1.1.5...
-$ script/server mongrel
-=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
-=> Rails 2.2.0 application starting on http://0.0.0.0:3000
+$ rails server mongrel
+=> Booting Mongrel (use 'rails server webrick' to force WEBrick)
+=> Rails 3.0.0 application starting on http://0.0.0.0:3000
...
</shell>
@@ -481,7 +481,7 @@ I got assigned some args:
Then we'll make sure it got included in the list of available generators:
<shell>
-$ ./script/generate
+$ rails generate
...
...
Installed Generators
@@ -491,7 +491,7 @@ Installed Generators
SWEET! Now let's generate some text, yeah!
<shell>
-$ ./script/generate tutorial_test arg1 arg2 arg3
+$ rails generate tutorial_test arg1 arg2 arg3
exists public
create public/tutorial.txt
</shell>
Oops, something went wrong.

2 comments on commit f44a0b1

@fxn
Member
fxn commented on f44a0b1 Feb 6, 2010

Hey, the change in the release notes is not correct. Comments depict previous usage.

Please sign in to comment.