aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG150
-rw-r--r--railties/README.rdoc2
-rw-r--r--railties/guides/assets/stylesheets/main.css28
-rw-r--r--railties/guides/rails_guides/generator.rb14
-rw-r--r--railties/guides/source/2_3_release_notes.textile10
-rw-r--r--railties/guides/source/action_controller_overview.textile14
-rw-r--r--railties/guides/source/action_view_overview.textile88
-rw-r--r--railties/guides/source/active_record_basics.textile4
-rw-r--r--railties/guides/source/active_record_querying.textile12
-rw-r--r--railties/guides/source/active_record_validations_callbacks.textile40
-rw-r--r--railties/guides/source/active_support_core_extensions.textile16
-rw-r--r--railties/guides/source/ajax_on_rails.textile34
-rw-r--r--railties/guides/source/api_documentation_guidelines.textile4
-rw-r--r--railties/guides/source/association_basics.textile4
-rw-r--r--railties/guides/source/caching_with_rails.textile10
-rw-r--r--railties/guides/source/command_line.textile4
-rw-r--r--railties/guides/source/configuring.textile10
-rw-r--r--railties/guides/source/getting_started.textile22
-rw-r--r--railties/guides/source/i18n.textile2
-rw-r--r--railties/guides/source/initialization.textile110
-rw-r--r--railties/guides/source/layouts_and_rendering.textile18
-rw-r--r--railties/guides/source/nested_model_forms.textile14
-rw-r--r--railties/guides/source/plugins.textile2
-rw-r--r--railties/guides/source/rails_application_templates.textile4
-rw-r--r--railties/guides/source/routing.textile4
-rw-r--r--railties/guides/source/security.textile2
-rw-r--r--railties/guides/w3c_validator.rb18
-rw-r--r--railties/lib/rails/code_statistics.rb8
-rw-r--r--railties/lib/rails/generators/base.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js2
-rw-r--r--railties/lib/rails/generators/rails/generator/USAGE2
-rw-r--r--railties/lib/rails/generators/rails/migration/USAGE8
-rw-r--r--railties/lib/rails/generators/rails/plugin/USAGE2
-rw-r--r--railties/lib/rails/generators/rails/resource/resource_generator.rb4
-rw-r--r--railties/lib/rails/plugin.rb2
-rw-r--r--railties/lib/rails/railtie.rb4
-rw-r--r--railties/lib/rails/script_rails_loader.rb4
-rw-r--r--railties/lib/rails/tasks/documentation.rake8
-rw-r--r--railties/test/application/loading_test.rb6
-rw-r--r--railties/test/application/rake_test.rb2
-rw-r--r--railties/test/generators/actions_test.rb4
-rw-r--r--railties/test/generators/app_generator_test.rb2
-rw-r--r--railties/test/railties/railtie_test.rb2
-rw-r--r--railties/test/script_rails_loader_test.rb8
44 files changed, 355 insertions, 355 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index fc1ec340c7..df6718764e 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -46,7 +46,7 @@
* Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example:
./script/generate scaffold post title:string can now be called as rails g scaffold post title:string
-
+
Run rails --help inside an app for more help.
* Removed config/initializers/new_rails_defaults.rb as all frameworks now follow the settings from it [DHH]
@@ -68,7 +68,7 @@
cookies.permanent.signed[:remember_me] = current_user.id
# => Set-Cookie: discount=BAhU--848956038e692d7046deab32b7131856ab20e14e; path=/; expires=Sun, 16-Dec-2029 03:24:16 GMT
-
+
...to use the signed cookies, you need to set a secret to ActionController::Base.cookie_verifier_secret (automatically done in config/initializers/cookie_verification_secret.rb for new Rails applications).
* Added config/initializers/cookie_verification_secret.rb with an auto-generated secret for using ActionController::Base#cookies.signed [DHH]
@@ -101,42 +101,42 @@
* Add "-m/--template" option to Rails generator to apply a template to the generated application. [Jeremy McAnally]
This has been extracted from rg - http://github.com/jeremymcanally/rg
-
+
Example:
-
+
# template.rb
-
+
# Install plugins from git or svn
plugin "will-paginate", :git => "git://github.com/mislav/will_paginate.git"
plugin "old-restful-auth", :svn => "http://svn.techno-weenie.net/projects/plugins/restful_authentication/"
-
+
# Add gems to environment.rb
gem "jeremymcanally-context"
gem "bluecloth"
-
+
# Vendor file. Data in a string or...
vendor("borrowed.rb", <<CODE
def helpful_method
do_something_helpful_here
end
CODE
-
+
# ...file data from block return value.
# #initializer creates a new initializer file
initializer("crypto.rb") do
salt = "--#{Time.now}--#{rand}--#{srand(Time.now.to_i)}"
-
+
"SPECIAL_SALT = '#{salt}'"
end
-
+
Usage:
-
+
To use a template, provide a file path or URL:
-
+
1. Using a local file :
rails <application name> -m /path/to/my/template.rb
-
+
2. Or directly from a URL :
rails <application name> --template=http://gist.github.com/31208.txt
@@ -235,7 +235,7 @@
rake gems:unpack # unpacks all gems
rake gems:unpack GEM=mygem # unpacks only the gem 'mygem'
-
+
rake gems:build # builds all unpacked gems
rake gems:build GEM=mygem # builds only the gem 'mygem'
@@ -246,16 +246,16 @@
* Allow files in plugins to be reloaded like the rest of the application. [Rick Olson]
Enables or disables plugin reloading.
-
+
config.reload_plugins = true
-
+
You can get around this setting per plugin.
If #reload_plugins? == false (DEFAULT), add this to your plugin's init.rb to make it reloadable:
-
+
Dependencies.load_once_paths.delete lib_path
-
+
If #reload_plugins? == true, add this to your plugin's init.rb to only load it once:
-
+
Dependencies.load_once_paths << lib_path
* Small tweak to allow plugins to specify gem dependencies. [Rick Olson]
@@ -280,13 +280,13 @@
config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
config.gem "aws-s3", :lib => "aws/s3"
end
-
+
# List required gems.
rake gems
-
+
# Install all required gems:
rake gems:install
-
+
# Unpack specified gem to vendor/gems/gem_name-x.x.x
rake gems:unpack GEM=bj
@@ -473,9 +473,9 @@ databases on localhost. #9753 [Trevor Wennblom]
For example:
ruby script/generation migration AddSomeStuffToCustomers first_name:string last_name:string
-
+
or
-
+
ruby script/generation migration RemoveSomeStuffFromCustomers first_name:string last_name:string
* Add ActiveResource to Rails::Info. Closes #8741 [Chris Kampmeier]
@@ -535,13 +535,13 @@ databases on localhost. #9753 [Trevor Wennblom]
* Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [David Heinemeier Hansson]
To use the new debugger, start your server with script/server --debugger and insert a call to 'debugger'
- (instead of 'breakpoint') where you want to jump into the debugger.
-
+ (instead of 'breakpoint') where you want to jump into the debugger.
+
BACKWARDS INCOMPATIBILITY NOTE: You must remove the default line 12 from config/environments/development.rb:
-
+
config.breakpoint_server = true
-
- This configuration option is no longer available. Rails will fail to start in development mode as long as
+
+ This configuration option is no longer available. Rails will fail to start in development mode as long as
that's still present.
* Resource scaffolding returns the created entity.to_xml. [Jeremy Kemper]
@@ -553,7 +553,7 @@ databases on localhost. #9753 [Trevor Wennblom]
* Include Active Resource instead of Action Web Service [David Heinemeier Hansson] You can add AWS back with this in config/environment.rb:
config.load_paths += %W( #{RAILS_ROOT}/vendor/rails/actionwebservice/lib )
-
+
...or just gem 'actionwebservice'
* Give generate scaffold a more descriptive database message. Closes #7316 [Jeremy McAnally]
@@ -566,7 +566,7 @@ databases on localhost. #9753 [Trevor Wennblom]
* Windows: include MinGW in RUBY_PLATFORM check. #2982 [okkez000@gmail.com, Kaspar Schiess]
-* Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.]
+* Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.]
* Split plugin location and loading out of the initializer and into a new Plugin namespace, which includes Plugin::Locater and Plugin::Loader. The loader class that is used can be customized using the config.plugin_loader option. Those monkey patching the plugin loading subsystem take note, the internals changing here will likely break your modifications. The good news is that it should be substantially easier to hook into the plugin locating and loading process now. [Marcel Molina Jr.]
@@ -602,7 +602,7 @@ databases on localhost. #9753 [Trevor Wennblom]
* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson]
If you really want your plugins to reload, add this to the very top of init.rb:
-
+
Dependencies.load_once_paths.delete(lib_path)
* Allow config.to_prepare to work, make the dispatcher safe to 're require'. [Michael Koziarski, Nicholas Seckar]
@@ -724,9 +724,9 @@ databases on localhost. #9753 [Trevor Wennblom]
* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As
documented in initializer.rb, the workaround is:
-
+
config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/']
-
+
References #6031. [Nicholas Seckar]
* Update to script.aculo.us 1.6.3 [Thomas Fuchs]
@@ -811,10 +811,10 @@ References #6031. [Nicholas Seckar]
0002 def show
0003-> breakpoint
0004 end
- 0005
+ 0005
0006 def index
0007 end
- 0008
+ 0008
=> "/path/to/rails/root/app/controllers/top_controller.rb"
irb(#<TopController:0x40822a68>):004:0> show_call_stack 3
@@ -905,7 +905,7 @@ References #6031. [Nicholas Seckar]
* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson]
If you really want your plugins to reload, add this to the very top of init.rb:
-
+
Dependencies.load_once_paths.delete(lib_path)
* Fix scaffold_resource generator so it respects the --pretend argument when creating the routes file. Closes #6852 [fearoffish]
@@ -1011,9 +1011,9 @@ References #6031. [Nicholas Seckar]
* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As
documented in initializer.rb, the workaround is:
-
+
config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/']
-
+
References #6031. [Nicholas Seckar]
* Update to script.aculo.us 1.6.3 [Thomas Fuchs]
@@ -1094,10 +1094,10 @@ References #6031. [Nicholas Seckar]
0002 def show
0003-> breakpoint
0004 end
- 0005
+ 0005
0006 def index
0007 end
- 0008
+ 0008
=> "/path/to/rails/root/app/controllers/top_controller.rb"
irb(#<TopController:0x40822a68>):004:0> show_call_stack 3
@@ -1332,7 +1332,7 @@ References #6031. [Nicholas Seckar]
* Changed the default session configuration to place sessions in tmp/sessions, if that directory is available, instead of /tmp (this essentially means a goodbye to 9/10 White Screen of Death errors and should have web hosting firms around the world cheering) [David Heinemeier Hansson]
-* Added tmp/sessions, tmp/cache, and tmp/sockets as default directories in the Rails skeleton [David Heinemeier Hansson]
+* Added tmp/sessions, tmp/cache, and tmp/sockets as default directories in the Rails skeleton [David Heinemeier Hansson]
* Added that script/generate model will now automatically create a migration file for the model created. This can be turned off by calling the generator with --skip-migration [David Heinemeier Hansson]
@@ -1711,7 +1711,7 @@ References #6031. [Nicholas Seckar]
# runs the one statement 10 times
script/benchmarker 10 'Person.expensive_method(10)'
-
+
# pits the two statements against each other with 50 runs each
script/benchmarker 50 'Person.expensive_method(10)' 'Person.cheap_method(10)'
@@ -1751,18 +1751,18 @@ References #6031. [Nicholas Seckar]
* Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Lütke]
* Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples:
-
+
./script/runner 'ReminderService.deliver'
./script/runner 'Mailer.receive(STDIN.read)'
-
+
This makes it easier to do CRON and postfix scripts without actually making a script just to trigger 1 line of code.
* Fixed webrick_server cookie handling to allow multiple cookes to be set at once #800, #813 [dave@cherryville.org]
* Fixed the Rakefile's interaction with postgresql to:
- 1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
- passwords when connecting to a remote db and local socket connections.
+ 1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
+ passwords when connecting to a remote db and local socket connections.
2. Add a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik]
3. Quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson]
4. Use the port if available #875 [madrobby]
@@ -1825,10 +1825,10 @@ References #6031. [Nicholas Seckar]
Controller: components/list/items_controller.rb
(holds a List::ItemsController class with uses_component_template_root called)
-
+
Model : components/list/item.rb
(namespace is still shared, so an Item model in app/models will take precedence)
-
+
Views : components/list/items/show.rhtml
@@ -1921,11 +1921,11 @@ References #6031. [Nicholas Seckar]
* Fixed dependency management to happen in a unified fashion for Active Record and Action Pack using the new Dependencies module. This means that
the environment options needs to change from:
-
+
Before in development.rb:
ActionController::Base.reload_dependencies = true  
ActiveRecord::Base.reload_associations     = true
-
+
Now in development.rb:
Dependencies.mechanism = :load
@@ -1979,41 +1979,41 @@ References #6031. [Nicholas Seckar]
* Added breakpoint support through the script/breakpointer client. This means that you can break out of execution at any point in
the code, investigate and change the model, AND then resume execution! Example:
-
+
class WeblogController < ActionController::Base
def index
@posts = Post.find_all
breakpoint "Breaking out from the list"
end
end
-
- So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window.
+
+ So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window.
Here you can do things like:
-
+
Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
>> @posts.inspect
- => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
>> @posts.first.title = "hello from a breakpoint"
=> "hello from a breakpoint"
...and even better is that you can examine how your runtime objects actually work:
- >> f = @posts.first
+ >> f = @posts.first
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
>> f.
Display all 152 possibilities? (y or n)
-
+
Finally, when you're ready to resume execution, you press CTRL-D
* Changed environments to be configurable through an environment variable. By default, the environment is "development", but you
can change that and set your own by configuring the Apache vhost with a string like (mod_env must be available on the server):
-
+
SetEnv RAILS_ENV production
-
+
...if you're using WEBrick, you can pick the environment to use with the command-line parameters -e/--environment, like this:
-
+
ruby public/dispatcher.servlet -e production
* Added a new default environment called "development", which leaves the production environment to be tuned exclusively for that.
@@ -2028,11 +2028,11 @@ References #6031. [Nicholas Seckar]
app/controllers/account_controller.rb # URL: /account/
app/controllers/admin/account_controller.rb # URL: /admin/account/
-
+
NOTE: You need to update your public/.htaccess with the new rules to pick it up
-* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use
- those environments for development. This is turned on by default, but can be turned off with
+* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use
+ those environments for development. This is turned on by default, but can be turned off with
ActiveRecord::Base.reload_associations = false and ActionController::Base.reload_dependencies = false in production environments.
* Added support for sub-directories in app/models. So now you can have something like Basecamp with:
@@ -2041,7 +2041,7 @@ References #6031. [Nicholas Seckar]
app/models/project
app/models/participants
app/models/settings
-
+
It's poor man's namespacing, but only for file-system organization. You still require files just like before.
Nothing changes inside the files themselves.
@@ -2061,7 +2061,7 @@ References #6031. [Nicholas Seckar]
@david.projects << @new_project
breakpoint "Let's have a closer look at @david"
end
-
+
You need to install dev-utils yourself for this to work ("gem install dev-util").
* Added shared generator behavior so future upgrades should be possible without manually copying over files [Jeremy Kemper]
@@ -2120,7 +2120,7 @@ References #6031. [Nicholas Seckar]
*0.7.0*
-* Added an optional second argument to the new_model script that allows the programmer to specify the table name,
+* Added an optional second argument to the new_model script that allows the programmer to specify the table name,
which will used to generate a custom table_name method in the model and will also be used in the creation of fixtures.
[Kevin Radloff]
@@ -2134,8 +2134,8 @@ References #6031. [Nicholas Seckar]
* create_fixtures in both the functional and unit test helper now turns off the log during fixture generation
and can generate more than one fixture at a time. Which makes it possible for assignments like:
-
- @people, @projects, @project_access, @companies, @accounts =
+
+ @people, @projects, @project_access, @companies, @accounts =
create_fixtures "people", "projects", "project_access", "companies", "accounts"
* Upgraded to Action Pack 0.8.5 (locally-scoped variables, partials, advanced send_file)
@@ -2147,7 +2147,7 @@ References #6031. [Nicholas Seckar]
* No longer specifies a template for rdoc, so it'll use whatever is default (you can change it in the rakefile)
-* The new_model generator will now use the same rules for plural wordings as Active Record
+* The new_model generator will now use the same rules for plural wordings as Active Record
(so Category will give categories, not categorys) [Kevin Radloff]
* dispatch.fcgi now sets FCGI_PURE_RUBY to true to ensure that it's the Ruby version that's loaded [danp]
@@ -2173,13 +2173,13 @@ References #6031. [Nicholas Seckar]
* Added environments that can be included from any script to get the full Active Record and Action Controller
context running. This can be used by maintenance scripts or to interact with the model through IRB. Example:
-
+
require 'config/environments/production'
-
+
for account in Account.find_all
account.recalculate_interests
end
-
+
A short migration script for an account model that had it's interest calculation strategy changed.
* Accessing the index of a controller with "/weblog" will now redirect to "/weblog/" (only on Apache, not WEBrick)
@@ -2202,7 +2202,7 @@ References #6031. [Nicholas Seckar]
* Added lib in root as a place to store app specific libraries
-* Added lib and vendor to load_path, so anything store within can be loaded directly.
+* Added lib and vendor to load_path, so anything store within can be loaded directly.
Hence lib/redcloth.rb can be loaded with require "redcloth"
* Upgraded to Action Pack 0.7.8 (lots of fixes)
@@ -2216,7 +2216,7 @@ References #6031. [Nicholas Seckar]
* Updated the generated template stubs to valid XHTML files
-* Ensure that controllers generated are capitalized, so "new_controller TodoLists"
+* Ensure that controllers generated are capitalized, so "new_controller TodoLists"
gives the same as "new_controller Todolists" and "new_controller todolists".
diff --git a/railties/README.rdoc b/railties/README.rdoc
index a1718a7d96..789d5255b7 100644
--- a/railties/README.rdoc
+++ b/railties/README.rdoc
@@ -15,7 +15,7 @@ The latest version of Railties can be installed with Rubygems:
* gem install railties
-Documentation can be found at
+Documentation can be found at
* http://api.rubyonrails.org
diff --git a/railties/guides/assets/stylesheets/main.css b/railties/guides/assets/stylesheets/main.css
index bab0b7a9d9..7e6dfbdb51 100644
--- a/railties/guides/assets/stylesheets/main.css
+++ b/railties/guides/assets/stylesheets/main.css
@@ -22,7 +22,7 @@ ol { list-style-type: decimal; }
dl { margin: 0 0 1.5em 0; }
dl dt { font-weight: bold; }
dd { margin-left: 1.5em;}
-
+
pre,code { margin: 1.5em 0; white-space: pre; overflow: auto; }
pre,code,tt { font: 1em 'andale mono', 'lucida console', monospace; line-height: 1.5; }
@@ -53,7 +53,7 @@ table {
background: #FFF;
border-collapse: collapse;
}
-
+
table th, table td {
padding: 0.25em 1em;
border: 1px solid #CCC;
@@ -76,7 +76,7 @@ body {
font-family: Helvetica, Arial, sans-serif;
font-size: 87.5%;
line-height: 1.5em;
- background: #222;
+ background: #222;
color: #999;
}
@@ -114,7 +114,7 @@ body {
#mainCol {
width: 45em;
margin-left: 2em;
- }
+ }
#subCol {
position: absolute;
@@ -127,7 +127,7 @@ body {
font-size: 0.9285em;
line-height: 1.3846em;
}
-
+
#extraCol {display: none;}
#footer {
@@ -180,7 +180,7 @@ a, a:link, a:visited {
#header .nav .index a {
background: #980905 url(../images/nav_arrow.gif) no-repeat right top;
- padding-right: 1em;
+ padding-right: 1em;
position: relative;
z-index: 15;
padding-bottom: 0.125em;
@@ -246,7 +246,7 @@ h3 {
margin: 0.875em 0 0.2916em;
font-weight: bold;
}
-
+
h4 {
font-size: 1.2857em;
line-height: 1.2em;
@@ -261,7 +261,7 @@ h5 {
font-weight: bold;
}
-h6 {
+h6 {
font-size: 1em;
line-height: 1.5em;
margin: 1em 0 .5em;
@@ -367,7 +367,7 @@ tt {
div.code_container {
background: #EEE url(../images/tab_grey.gif) no-repeat left top;
- padding: 0.25em 1em 0.5em 48px;
+ padding: 0.25em 1em 0.5em 48px;
}
code {
@@ -411,15 +411,15 @@ code {
padding: 0 0 1em;
font-size: 1.1667em;
}
-
+
/* Clearing
--------------------------------------- */
.clearfix:after {
- content: ".";
- display: block;
- height: 0;
- clear: both;
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
visibility: hidden;
}
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb
index bb7cdb6756..5a5ce54503 100644
--- a/railties/guides/rails_guides/generator.rb
+++ b/railties/guides/rails_guides/generator.rb
@@ -32,7 +32,7 @@
#
# Separate many using commas:
#
-# # generates only
+# # generates only
# ONLY=assoc,migrations ruby rails_guides.rb
#
# Note that if you are working on a guide generation will by default process
@@ -77,7 +77,7 @@ module RailsGuides
def initialize_dirs(output)
@guides_dir = File.join(File.dirname(__FILE__), '..')
@source_dir = File.join(@guides_dir, "source")
- @output_dir = output || File.join(@guides_dir, "output")
+ @output_dir = output || File.join(@guides_dir, "output")
end
def create_output_dir_if_needed
@@ -116,7 +116,7 @@ module RailsGuides
def output_file_for(guide)
guide.sub(GUIDES_RE, '.html')
end
-
+
def generate?(source_file, output_file)
fin = File.join(source_dir, source_file)
fout = File.join(output_dir, output_file)
@@ -213,9 +213,9 @@ module RailsGuides
code_blocks << %{<div class="code_container"><code class="#{css_class}">#{es}</code></div>}
"\ndirty_workaround_for_notextile_#{code_blocks.size - 1}\n"
end
-
+
body = yield body
-
+
body.gsub(%r{<p>dirty_workaround_for_notextile_(\d+)</p>}) do |_|
code_blocks[$1.to_i]
end
@@ -225,7 +225,7 @@ module RailsGuides
anchors = extract_anchors(html)
check_fragment_identifiers(html, anchors)
end
-
+
def extract_anchors(html)
# Textile generates headers with IDs computed from titles.
anchors = Set.new
@@ -241,7 +241,7 @@ module RailsGuides
anchors += Set.new(html.scan(/<p\s+class="footnote"\s+id="([^"]+)/).flatten)
return anchors
end
-
+
def check_fragment_identifiers(html, anchors)
html.scan(/<a\s+href="#([^"]+)/).flatten.each do |fragment_identifier|
next if fragment_identifier == 'mainCol' # in layout, jumps to some DIV
diff --git a/railties/guides/source/2_3_release_notes.textile b/railties/guides/source/2_3_release_notes.textile
index f3530c4ddd..72fe723687 100644
--- a/railties/guides/source/2_3_release_notes.textile
+++ b/railties/guides/source/2_3_release_notes.textile
@@ -53,7 +53,7 @@ The "Ruby on Rails guides":http://guides.rubyonrails.org/ project has published
h3. Ruby 1.9.1 Support
-Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 or the now-released Ruby 1.9.1. You should be aware, though, that moving to 1.9.1 entails checking all of the data adapters, plugins, and other code that you depend on for Ruby 1.9.1 compatibility, as well as Rails core.
+Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 or the now-released Ruby 1.9.1. You should be aware, though, that moving to 1.9.1 entails checking all of the data adapters, plugins, and other code that you depend on for Ruby 1.9.1 compatibility, as well as Rails core.
h3. Active Record
@@ -77,7 +77,7 @@ Turning on nested attributes enables a number of things: automatic (and atomic)
You can also specify requirements for any new records that are added via nested attributes using the +:reject_if+ option:
<ruby>
-accepts_nested_attributes_for :author,
+accepts_nested_attributes_for :author,
:reject_if => proc { |attributes| attributes['name'].blank? }
</ruby>
@@ -149,7 +149,7 @@ end
Note that you should only use this method for batch processing: for small numbers of records (less than 1000), you should just use the regular find methods with your own loop.
-* More Information (at that point the convenience method was called just +each+):
+* More Information (at that point the convenience method was called just +each+):
** "Rails 2.3: Batch Finding":http://afreshcup.com/2009/02/23/rails-23-batch-finding/
** "What's New in Edge Rails: Batched Find":http://ryandaigle.com/articles/2009/2/23/what-s-new-in-edge-rails-batched-find
@@ -449,7 +449,7 @@ returns
<option>joke</option>
<option>poem</option>
<option disabled=“disabled“>private</option>
-</select>
+</select>
</ruby>
You can also use an anonymous function to determine at runtime which options from collections will be selected and/or disabled:
@@ -502,7 +502,7 @@ The support for XML parsing in ActiveSupport has been made more flexible by allo
XmlMini.backend = 'LibXML'
</ruby>
-* Lead Contributor: "Bart ten Brinke":http://www.movesonrails.com/
+* Lead Contributor: "Bart ten Brinke":http://www.movesonrails.com/
* Lead Contributor: "Aaron Patterson":http://tenderlovemaking.com/
h4. Fractional seconds for TimeWithZone
diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile
index ec2d5b2787..b38ae07043 100644
--- a/railties/guides/source/action_controller_overview.textile
+++ b/railties/guides/source/action_controller_overview.textile
@@ -115,7 +115,7 @@ h4. Routing Parameters
The +params+ hash will always contain the +:controller+ and +:action+ keys, but you should use the methods +controller_name+ and +action_name+ instead to access these values. Any other parameters defined by the routing, such as +:id+ will also be available. As an example, consider a listing of clients where the list can show either active or inactive clients. We can add a route which captures the +:status+ parameter in a "pretty" URL:
<ruby>
-map.connect "/clients/:status",
+map.connect "/clients/:status",
:controller => "clients",
:action => "index",
:foo => "bar"
@@ -296,7 +296,7 @@ class MainController < ApplicationController
# Will persist all flash values.
flash.keep
- # You can also use a key to keep only some kind of value.
+ # You can also use a key to keep only some kind of value.
# flash.keep(:notice)
redirect_to users_url
end
@@ -369,14 +369,14 @@ class UsersController < ApplicationController
end
</ruby>
-Notice that in the above case code is <tt>render :xml => @users</tt> and not <tt>render :xml => @users.to_xml</tt>. That is because if the input is not string then rails automatically invokes +to_xml+ .
+Notice that in the above case code is <tt>render :xml => @users</tt> and not <tt>render :xml => @users.to_xml</tt>. That is because if the input is not string then rails automatically invokes +to_xml+ .
h3. Filters
-Filters are methods that are run before, after or "around" a controller action.
+Filters are methods that are run before, after or "around" a controller action.
-Filters are inherited, so if you set a filter on +ApplicationController+, it will be run on every controller in your application.
+Filters are inherited, so if you set a filter on +ApplicationController+, it will be run on every controller in your application.
Before filters may halt the request cycle. A common before filter is one which requires that a user is logged in for an action to be run. You can define the filter method this way:
@@ -536,7 +536,7 @@ You will see how the token gets added as a hidden field:
<html>
<form action="/users/1" method="post">
-<input type="hidden"
+<input type="hidden"
value="67250ab105eb5ad10851c00a5621854a23af5489"
name="authenticity_token"/>
<!-- fields -->
@@ -659,7 +659,7 @@ class ClientsController < ApplicationController
# returns it. The user will get the PDF as a file download.
def download_pdf
client = Client.find(params[:id])
- send_data generate_pdf(client),
+ send_data generate_pdf(client),
:filename => "#{client.name}.pdf",
:type => "application/pdf"
end
diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile
index 8b5eda0973..e242cdaf73 100644
--- a/railties/guides/source/action_view_overview.textile
+++ b/railties/guides/source/action_view_overview.textile
@@ -12,9 +12,9 @@ endprologue.
h3. What is Action View?
-Action View and Action Controller are the two major components of Action Pack. In Rails, web requests are handled by Action Pack, which splits the work into a controller part (performing the logic) and a view part (rendering a template). Typically, Action Controller will be concerned with communicating with the database and performing CRUD actions where necessary. Action View is then responsible for compiling the response.
+Action View and Action Controller are the two major components of Action Pack. In Rails, web requests are handled by Action Pack, which splits the work into a controller part (performing the logic) and a view part (rendering a template). Typically, Action Controller will be concerned with communicating with the database and performing CRUD actions where necessary. Action View is then responsible for compiling the response.
-Action View templates are written using embedded Ruby in tags mingled with HTML. To avoid cluttering the templates with boilerplate code, a number of helper classes provide common behavior for forms, dates, and strings. It's also easy to add new helpers to your application as it evolves.
+Action View templates are written using embedded Ruby in tags mingled with HTML. To avoid cluttering the templates with boilerplate code, a number of helper classes provide common behavior for forms, dates, and strings. It's also easy to add new helpers to your application as it evolves.
Note: Some features of Action View are tied to Active Record, but that doesn't mean that Action View depends on Active Record. Action View is an independent package that can be used with any sort of backend.
@@ -24,7 +24,7 @@ TODO...
h3. Using Action View outside of Rails
-Action View works well with Action Record, but it can also be used with other Ruby tools. We can demonstrate this by creating a small "Rack":http://rack.rubyforge.org/ application that includes Action View functionality. This may be useful, for example, if you'd like access to Action View's helpers in a Rack application.
+Action View works well with Action Record, but it can also be used with other Ruby tools. We can demonstrate this by creating a small "Rack":http://rack.rubyforge.org/ application that includes Action View functionality. This may be useful, for example, if you'd like access to Action View's helpers in a Rack application.
Let's start by ensuring that you have the Action Pack and Rack gems installed:
@@ -55,11 +55,11 @@ We can see this all come together by starting up the application and then visiti
ruby hello_world.rb
</shell>
-TODO needs a screenshot? I have one - not sure where to put it.
+TODO needs a screenshot? I have one - not sure where to put it.
-Notice how 'hello world' has been converted into 'Hello World' by the +titleize+ helper method.
+Notice how 'hello world' has been converted into 'Hello World' by the +titleize+ helper method.
-Action View can also be used with "Sinatra":http://www.sinatrarb.com/ in the same way.
+Action View can also be used with "Sinatra":http://www.sinatrarb.com/ in the same way.
Let's start by ensuring that you have the Action Pack and Sinatra gems installed:
@@ -90,7 +90,7 @@ ruby hello_world.rb
Once the application is running, you can see Sinatra and Action View working together by visiting +http://localhost:4567/+
-TODO needs a screenshot? I have one - not sure where to put it.
+TODO needs a screenshot? I have one - not sure where to put it.
h3. Templates, Partials and Layouts
@@ -172,7 +172,7 @@ TODO...
h3. Overview of all the helpers provided by Action View
-The following is only a brief overview summary of the helpers available in Action View. It's recommended that you review the API Documentation, which covers all of the helpers in more detail, but this should serve as a good starting point.
+The following is only a brief overview summary of the helpers available in Action View. It's recommended that you review the API Documentation, which covers all of the helpers in more detail, but this should serve as a good starting point.
h4. ActiveRecordHelper
@@ -196,7 +196,7 @@ error_messages_for "post"
h5. form
-Returns a form with inputs for all attributes of the specified Active Record object. For example, let's say we have a +@post+ with attributes named +title+ of type +String+ and +body+ of type +Text+. Calling +form+ would produce a form to creating a new post with inputs for those attributes.
+Returns a form with inputs for all attributes of the specified Active Record object. For example, let's say we have a +@post+ with attributes named +title+ of type +String+ and +body+ of type +Text+. Calling +form+ would produce a form to creating a new post with inputs for those attributes.
<ruby>
form("post")
@@ -220,24 +220,24 @@ Typically, +form_for+ is used instead of +form+ because it doesn't automatically
h5. input
-Returns a default input tag for the type of object returned by the method.
+Returns a default input tag for the type of object returned by the method.
For example, if +@post+ has an attribute +title+ mapped to a +String+ column that holds "Hello World":
<ruby>
-input("post", "title") # =>
+input("post", "title") # =>
<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
</ruby>
h4. AssetTagHelper
-This module provides methods for generating HTML that links views to assets such as images, javascripts, stylesheets, and feeds.
+This module provides methods for generating HTML that links views to assets such as images, javascripts, stylesheets, and feeds.
By default, Rails links to these assets on the current host in the public folder, but you can direct Rails to link to assets from a dedicated assets server by setting +ActionController::Base.asset_host+ in your +config/environment.rb+. For example, let's say your asset host is +assets.example.com+:
<ruby>
ActionController::Base.asset_host = "assets.example.com"
-image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" />
+image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" />
</ruby>
h5. register_javascript_expansion
@@ -301,10 +301,10 @@ Returns an html script tag for each of the sources provided. You can pass in the
<ruby>
javascript_include_tag "common" # =>
- <script type="text/javascript" src="/javascripts/common.js"></script>
+ <script type="text/javascript" src="/javascripts/common.js"></script>
</ruby>
-To include the Prototype and Scriptaculous javascript libraries in your application, pass +:defaults+ as the source. When using +:defaults+, if an +application.js+ file exists in your +public/javascripts+ directory, it will be included as well.
+To include the Prototype and Scriptaculous javascript libraries in your application, pass +:defaults+ as the source. When using +:defaults+, if an +application.js+ file exists in your +public/javascripts+ directory, it will be included as well.
<ruby>
javascript_include_tag :defaults
@@ -319,8 +319,8 @@ javascript_include_tag :all
You can also cache multiple javascripts into one file, which requires less HTTP connections to download and can better be compressed by gzip (leading to faster transfers). Caching will only happen if +ActionController::Base.perform_caching+ is set to true (which is the case by default for the Rails production environment, but not for the development environment).
<ruby>
-javascript_include_tag :all, :cache => true # =>
- <script type="text/javascript" src="/javascripts/all.js"></script>
+javascript_include_tag :all, :cache => true # =>
+ <script type="text/javascript" src="/javascripts/all.js"></script>
</ruby>
h5. javascript_path
@@ -333,7 +333,7 @@ javascript_path "common" # => /javascripts/common.js
h5. stylesheet_link_tag
-Returns a stylesheet link tag for the sources specified as arguments. If you don't specify an extension, +.css+ will be appended automatically.
+Returns a stylesheet link tag for the sources specified as arguments. If you don't specify an extension, +.css+ will be appended automatically.
<ruby>
stylesheet_link_tag "application" # =>
@@ -346,7 +346,7 @@ You can also include all styles in the stylesheet directory using :all as the so
stylesheet_link_tag :all
</ruby>
-You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching is set to true (which is the case by default for the Rails production environment, but not for the development environment).
+You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching is set to true (which is the case by default for the Rails production environment, but not for the development environment).
<ruby>
stylesheet_link_tag :all, :cache => true
@@ -415,7 +415,7 @@ Allows you to measure the execution time of a block in a template and records th
<ruby>
<% benchmark "Process data files" do %>
<%= expensive_files_operation %>
-<% end %>
+<% end %>
</ruby>
This would add something like "Process data files (0.34523)" to the log, which you can then use to compare timings when optimizing your code.
@@ -455,7 +455,7 @@ The captured variable can then be used anywhere else.
<%= @greeting %>
</body>
</html>
-</ruby>
+</ruby>
h5. content_for
@@ -484,7 +484,7 @@ For example, let's say we have a standard application layout, but also a special
<% content_for :special_script do %>
<script type="text/javascript">alert('Hello!')</script>
-<% end %>
+<% end %>
</ruby>
h4. DateHelper
@@ -523,7 +523,7 @@ Returns a set of html select-tags (one for year, month, and day) pre-selected wi
select_date(Time.today + 6.days)
# Generates a date select that defaults to today (no specified date)
-select_date()
+select_date()
</ruby>
h5. select_datetime
@@ -535,7 +535,7 @@ Returns a set of html select-tags (one for year, month, day, hour, and minute) p
select_datetime(Time.now + 4.days)
# Generates a datetime select that defaults to today (no specified datetime)
-select_datetime()
+select_datetime()
</ruby>
h5. select_day
@@ -583,7 +583,7 @@ Returns a select tag with options for each of the seconds 0 through 59 with the
<ruby>
# Generates a select field for seconds that defaults to the seconds for the time provided
-select_second(Time.now + 16.minutes)
+select_second(Time.now + 16.minutes)
</ruby>
h5. select_time
@@ -592,7 +592,7 @@ Returns a set of html select-tags (one for hour and minute).
<ruby>
# Generates a time select that defaults to the time provided
-select_time(Time.now)
+select_time(Time.now)
</ruby>
h5. select_year
@@ -621,7 +621,7 @@ Returns a set of select tags (one for hour, minute and optionally second) pre-se
<ruby>
# Creates a time select tag that, when POSTed, will be stored in the order variable in the submitted attribute
-time_select("order", "submitted")
+time_select("order", "submitted")
</ruby>
h4. DebugHelper
@@ -711,7 +711,7 @@ Returns an file upload input tag tailored for accessing a specified attribute.
<ruby>
file_field(:user, :avatar)
-# => <input type="file" id="user_avatar" name="user[avatar]" />
+# => <input type="file" id="user_avatar" name="user[avatar]" />
</ruby>
h5. form_for
@@ -733,7 +733,7 @@ Returns a hidden input tag tailored for accessing a specified attribute.
<ruby>
hidden_field(:user, :token)
-# => <input type="hidden" id="user_token" name="user[token]" value="#{@user.token}" />
+# => <input type="hidden" id="user_token" name="user[token]" value="#{@user.token}" />
</ruby>
h5. label
@@ -751,7 +751,7 @@ Returns an input tag of the "password" type tailored for accessing a specified a
<ruby>
password_field(:login, :pass)
-# => <input type="text" id="login_pass" name="login[pass]" value="#{@login.pass}" />
+# => <input type="text" id="login_pass" name="login[pass]" value="#{@login.pass}" />
</ruby>
h5. radio_button
@@ -854,7 +854,7 @@ end
Sample usage:
-<ruby>
+<ruby>
option_groups_from_collection_for_select(@continents, :countries, :name, :id, :name, 3)
</ruby>
@@ -880,7 +880,7 @@ Note: Only the +optgroup+ and +option+ tags are returned, so you still have to w
h5. options_for_select
-Accepts a container (hash, array, enumerable, your type) and returns a string of option tags.
+Accepts a container (hash, array, enumerable, your type) and returns a string of option tags.
<ruby>
options_for_select([ "VISA", "MasterCard" ])
@@ -902,7 +902,7 @@ For example, imagine a loop iterating over each person in @project.people to gen
<ruby>
options_from_collection_for_select(@project.people, "id", "name")
# => <option value="#{person.id}">#{person.name}</option>
-</ruby>
+</ruby>
Note: Only the +option+ tags are returned, you have to wrap this call in a regular HTML +select+ tag.
@@ -949,7 +949,7 @@ Creates a check box form input tag.
<ruby>
check_box_tag 'accept'
-# => <input id="accept" name="accept" type="checkbox" value="1" />
+# => <input id="accept" name="accept" type="checkbox" value="1" />
</ruby>
h5. field_set_tag
@@ -965,7 +965,7 @@ Creates a field set for grouping HTML form elements.
h5. file_field_tag
-Creates a file upload field.
+Creates a file upload field.
If you are using file uploads then you will also need to set the multipart option for the form tag:
@@ -1173,7 +1173,7 @@ number_with_delimiter(12345678) # => 12,345,678
h5. number_with_precision
-Formats a number with the specified level of +precision+, which defaults to 3.
+Formats a number with the specified level of +precision+, which defaults to 3.
<ruby>
number_with_precision(111.2345) # => 111.235
@@ -1207,7 +1207,7 @@ form_remote_tag :html => { :action => url_for(:controller => "some", :action =>
would generate the following:
<html>
-<form action="/some/place" method="post" onsubmit="new Ajax.Request('',
+<form action="/some/place" method="post" onsubmit="new Ajax.Request('',
{asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">
</html>
@@ -1293,7 +1293,7 @@ Yields a JavaScriptGenerator and returns the generated JavaScript code. Use this
<ruby>
update_page do |page|
page.hide 'spinner'
-end
+end
</ruby>
h5. update_page_tag
@@ -1395,7 +1395,7 @@ h5. remove
Removes the DOM elements with the given ids from the page.
<ruby>
-page.remove 'person_23', 'person_9', 'person_2'
+page.remove 'person_23', 'person_9', 'person_2'
</ruby>
h5. replace
@@ -1420,7 +1420,7 @@ Returns a collection reference by finding it through a CSS pattern in the DOM.
<ruby>
page.select('p.welcome b').first.hide # => $$('p.welcome b').first().hide();
-</ruby>
+</ruby>
h5. show
@@ -1440,7 +1440,7 @@ Toggles the visibility of the DOM elements with the given ids. Example:
<ruby>
page.toggle 'person_14', 'person_12', 'person_23' # Hides the elements
-page.toggle 'person_14', 'person_12', 'person_23' # Shows the previously hidden elements
+page.toggle 'person_14', 'person_12', 'person_23' # Shows the previously hidden elements
</ruby>
h5. visual_effect
@@ -1455,11 +1455,11 @@ h3. Localized Views
Action View has the ability render different templates depending on the current locale.
-For example, suppose you have a Posts controller with a show action. By default, calling this action will render +app/views/posts/show.html.erb+. But if you set +I18n.locale = :de+, then +app/views/posts/show.de.html.erb+ will be rendered instead. If the localized template isn't present, the undecorated version will be used. This means you're not required to provide localized views for all cases, but they will be preferred and used if available.
+For example, suppose you have a Posts controller with a show action. By default, calling this action will render +app/views/posts/show.html.erb+. But if you set +I18n.locale = :de+, then +app/views/posts/show.de.html.erb+ will be rendered instead. If the localized template isn't present, the undecorated version will be used. This means you're not required to provide localized views for all cases, but they will be preferred and used if available.
You can use the same technique to localize the rescue files in your public directory. For example, setting +I18n.locale = :de+ and creating +public/500.de.html+ and +public/404.de.html+ would allow you to have localized rescue pages.
-Since Rails doesn't restrict the symbols that you use to set I18n.locale, you can leverage this system to display different content depending on anything you like. For example, suppose you have some "expert" users that should see different pages from "normal" users. You could add the following to +app/controllers/application.rb+:
+Since Rails doesn't restrict the symbols that you use to set I18n.locale, you can leverage this system to display different content depending on anything you like. For example, suppose you have some "expert" users that should see different pages from "normal" users. You could add the following to +app/controllers/application.rb+:
<ruby>
before_filter :set_expert_locale
@@ -1471,7 +1471,7 @@ end
Then you could create special views like +app/views/posts/show.expert.html.erb+ that would only be displayed to expert users.
-You can read more about the Rails Internationalization (I18n) API "here":i18n.html.
+You can read more about the Rails Internationalization (I18n) API "here":i18n.html.
h3. Changelog
diff --git a/railties/guides/source/active_record_basics.textile b/railties/guides/source/active_record_basics.textile
index e6ef2cdd20..f0081b48c0 100644
--- a/railties/guides/source/active_record_basics.textile
+++ b/railties/guides/source/active_record_basics.textile
@@ -16,7 +16,7 @@ Active Record is the M in "MVC":getting_started.html#the-mvc-architecture - the
h4. The Active Record Pattern
-Active Record was described by Martin Fowler in his book _Patterns of Enterprise Application Architecture_. In Active Record, objects carry both persistent data and behavior which operates on that data. Active Record takes the opinion that ensuring data access logic is part of the object will educate users of that object on how to write to and read from the database.
+Active Record was described by Martin Fowler in his book _Patterns of Enterprise Application Architecture_. In Active Record, objects carry both persistent data and behavior which operates on that data. Active Record takes the opinion that ensuring data access logic is part of the object will educate users of that object on how to write to and read from the database.
h4. Object Relational Mapping
@@ -132,7 +132,7 @@ CRUD is an acronym for the four verbs we use to operate on data: *C*reate, *R*ea
h4. Create
-Active Record objects can be created from a hash, a block or have its attributes manually set after creation. The _new_ method will return a new object while _create_ will return the object and save it to the database.
+Active Record objects can be created from a hash, a block or have its attributes manually set after creation. The _new_ method will return a new object while _create_ will return the object and save it to the database.
For example, given a model +User+ with attributes of +name+ and +occupation+, the _create_ method call will create and save a new record into the database:
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index 53095a2bd3..b54b5c116b 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -153,7 +153,7 @@ SELECT * FROM clients WHERE (clients.id IN (1,10))
h4. Retrieving Multiple Objects in Batches
-Sometimes you need to iterate over a large set of records. For example to send a newsletter to all users, to export some data, etc.
+Sometimes you need to iterate over a large set of records. For example to send a newsletter to all users, to export some data, etc.
The following may seem very straight forward at first:
@@ -674,7 +674,7 @@ Post.joins(:category, :comments)
This produces:
<sql>
-SELECT posts.* FROM posts
+SELECT posts.* FROM posts
INNER JOIN categories ON posts.category_id = categories.id
INNER JOIN comments ON comments.post_id = posts.id
</sql>
@@ -753,7 +753,7 @@ h4. Eager Loading Multiple Associations
Active Record lets you eager load any number of associations with a single +Model.find+ call by using an array, hash, or a nested hash of array/hash with the +includes+ method.
-h5. Array of Multiple Associations
+h5. Array of Multiple Associations
<ruby>
Post.includes(:category, :comments)
@@ -771,7 +771,7 @@ This will find the category with id 1 and eager load all of the associated posts
h4. Specifying Conditions on Eager Loaded Associations
-Even though Active Record lets you specify conditions on the eager loaded associations just like +joins+, the recommended way is to use "joins":#joining-tables instead.
+Even though Active Record lets you specify conditions on the eager loaded associations just like +joins+, the recommended way is to use "joins":#joining-tables instead.
h3. Dynamic Finders
@@ -807,8 +807,8 @@ h3. Finding by SQL
If you'd like to use your own SQL to find records in a table you can use +find_by_sql+. The +find_by_sql+ method will return an array of objects even if the underlying query returns just a single record. For example you could run this query:
<ruby>
-Client.find_by_sql("SELECT * FROM clients
- INNER JOIN orders ON clients.id = orders.client_id
+Client.find_by_sql("SELECT * FROM clients
+ INNER JOIN orders ON clients.id = orders.client_id
ORDER clients.created_at desc")
</ruby>
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile
index 37a65d211e..1e232422e3 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/railties/guides/source/active_record_validations_callbacks.textile
@@ -16,7 +16,7 @@ endprologue.
h3. The Object Life Cycle
-During the normal operation of a Rails application, objects may be created, updated, and destroyed. Active Record provides hooks into this <em>object life cycle</em> so that you can control your application and its data.
+During the normal operation of a Rails application, objects may be created, updated, and destroyed. Active Record provides hooks into this <em>object life cycle</em> so that you can control your application and its data.
Validations allow you to ensure that only valid data is stored in your database. Callbacks and observers allow you to trigger logic before or after an alteration of an object's state.
@@ -33,7 +33,7 @@ There are several ways to validate data before it is saved into your database, i
* Database constraints and/or stored procedures make the validation mechanisms database-dependent and can make testing and maintenance more difficult. However, if your database is used by other applications, it may be a good idea to use some constraints at the database level. Additionally, database-level validations can safely handle some things (such as uniqueness in heavily-used tables) that can be difficult to implement otherwise.
* Client-side validations can be useful, but are generally unreliable if used alone. If they are implemented using JavaScript, they may be bypassed if JavaScript is turned off in the user's browser. However, if combined with other techniques, client-side validation can be a convenient way to provide users with immediate feedback as they use your site.
* Controller-level validations can be tempting to use, but often become unwieldy and difficult to test and maintain. Whenever possible, it's a good idea to "keep your controllers skinny":http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model, as it will make your application a pleasure to work with in the long run.
-* Model-level validations are the best way to ensure that only valid data is saved into your database. They are database agnostic, cannot be bypassed by end users, and are convenient to test and maintain. Rails makes them easy to use, provides built-in helpers for common needs, and allows you to create your own validation methods as well.
+* Model-level validations are the best way to ensure that only valid data is saved into your database. They are database agnostic, cannot be bypassed by end users, and are convenient to test and maintain. Rails makes them easy to use, provides built-in helpers for common needs, and allows you to create your own validation methods as well.
h4. When Does Validation Happen?
@@ -116,7 +116,7 @@ end
=> #<Person id: nil, name: nil>
>> p.errors
=> {}
-
+
>> p.valid?
=> false
>> p.errors
@@ -126,7 +126,7 @@ end
=> #<Person id: nil, name: nil>
>> p.errors
=> {:name=>["can't be blank"]}
-
+
>> p.save
=> false
@@ -368,7 +368,7 @@ class LineItem < ActiveRecord::Base
end
</ruby>
-Since +false.blank?+ is true, if you want to validate the presence of a boolean field you should use +validates_inclusion_of :field_name, :in => [true, false]+.
+Since +false.blank?+ is true, if you want to validate the presence of a boolean field you should use +validates_inclusion_of :field_name, :in => [true, false]+.
The default error message for +validates_presence_of+ is "_can't be empty_".
@@ -550,9 +550,9 @@ end
h3. Creating Custom Validation Methods
-When the built-in validation helpers are not enough for your needs, you can write your own validation methods.
+When the built-in validation helpers are not enough for your needs, you can write your own validation methods.
-Simply create methods that verify the state of your models and add messages to the +errors+ collection when they are invalid. You must then register these methods by using one or more of the +validate+, +validate_on_create+ or +validate_on_update+ class methods, passing in the symbols for the validation methods' names.
+Simply create methods that verify the state of your models and add messages to the +errors+ collection when they are invalid. You must then register these methods by using one or more of the +validate+, +validate_on_create+ or +validate_on_update+ class methods, passing in the symbols for the validation methods' names.
You can pass more than one symbol for each class method and the respective validations will be run in the same order as they were registered.
@@ -593,7 +593,7 @@ end
h3. Working with Validation Errors
-In addition to the +valid?+ and +invalid?+ methods covered earlier, Rails provides a number of methods for working with the +errors+ collection and inquiring about the validity of objects.
+In addition to the +valid?+ and +invalid?+ methods covered earlier, Rails provides a number of methods for working with the +errors+ collection and inquiring about the validity of objects.
The following is a list of the most commonly used methods. Please refer to the +ActiveRecord::Errors+ documentation for a list of all the available methods.
@@ -611,7 +611,7 @@ person = Person.new
person.valid? # => false
person.errors
# => {:name => ["can't be blank", "is too short (minimum is 3 characters)"]}
-
+
person = Person.new(:name => "John Doe")
person.valid? # => true
person.errors # => []
@@ -660,7 +660,7 @@ person.errors[:name]
person.errors.full_messages
# => ["Name cannot contain the characters !@#%*()_-+="]
</ruby>
-
+
Another way to do this is using +[]=+ setter
<ruby>
@@ -739,7 +739,7 @@ person.errors.size # => 0
h3. Displaying Validation Errors in the View
-Rails provides built-in helpers to display the error messages of your models in your view templates.
+Rails provides built-in helpers to display the error messages of your models in your view templates.
h4. +error_messages+ and +error_messages_for+
@@ -811,7 +811,7 @@ The name of the class and the id can be changed with the +:class+ and +:id+ opti
h4. Customizing the Error Messages HTML
-By default, form fields with errors are displayed enclosed by a +div+ element with the +field_with_errors+ CSS class. However, it's possible to override that.
+By default, form fields with errors are displayed enclosed by a +div+ element with the +field_with_errors+ CSS class. However, it's possible to override that.
The way form fields with errors are treated is defined by +ActionView::Base.field_error_proc+. This is a +Proc+ that receives two parameters:
@@ -865,7 +865,7 @@ The macro-style class methods can also receive a block. Consider using this styl
class User < ActiveRecord::Base
validates_presence_of :login, :email
- before_create {|user| user.name = user.login.capitalize
+ before_create {|user| user.name = user.login.capitalize
if user.name.blank?}
end
</ruby>
@@ -967,7 +967,7 @@ The +after_initialize+ callback is triggered every time a new object of the clas
h3. Skipping Callbacks
-Just as with validations, it's also possible to skip callbacks. These methods should be used with caution, however, because important business rules and application logic may be kept in callbacks. Bypassing them without understanding the potential implications may lead to invalid data.
+Just as with validations, it's also possible to skip callbacks. These methods should be used with caution, however, because important business rules and application logic may be kept in callbacks. Bypassing them without understanding the potential implications may lead to invalid data.
* +decrement+
* +decrement_counter+
@@ -982,7 +982,7 @@ Just as with validations, it's also possible to skip callbacks. These methods sh
h3. Halting Execution
-As you start registering new callbacks for your models, they will be queued for execution. This queue will include all your model's validations, the registered callbacks, and the database operation to be executed.
+As you start registering new callbacks for your models, they will be queued for execution. This queue will include all your model's validations, the registered callbacks, and the database operation to be executed.
The whole callback chain is wrapped in a transaction. If any <em>before</em> callback method returns exactly +false+ or raises an exception the execution chain gets halted and a ROLLBACK is issued; <em>after</em> callbacks can only accomplish that by raising an exception.
@@ -990,11 +990,11 @@ WARNING. Raising an arbitrary exception may break code that expects +save+ and f
h3. Relational Callbacks
-Callbacks work through model relationships, and can even be defined by them. Let's take an example where a user has many posts. In our example, a user's posts should be destroyed if the user is destroyed. So, we'll add an +after_destroy+ callback to the +User+ model by way of its relationship to the +Post+ model.
+Callbacks work through model relationships, and can even be defined by them. Let's take an example where a user has many posts. In our example, a user's posts should be destroyed if the user is destroyed. So, we'll add an +after_destroy+ callback to the +User+ model by way of its relationship to the +Post+ model.
<ruby>
class User < ActiveRecord::Base
- has_many :posts, :dependent => :destroy
+ has_many :posts, :dependent => :destroy
end
class Post < ActiveRecord::Base
@@ -1069,7 +1069,7 @@ Here's an example where we create a class with an +after_destroy+ callback for a
<ruby>
class PictureFileCallbacks
def after_destroy(picture_file)
- File.delete(picture_file.filepath)
+ File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
end
end
@@ -1088,7 +1088,7 @@ Note that we needed to instantiate a new +PictureFileCallbacks+ object, since we
<ruby>
class PictureFileCallbacks
def self.after_destroy(picture_file)
- File.delete(picture_file.filepath)
+ File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
end
end
@@ -1144,7 +1144,7 @@ By default, Rails will simply strip "Observer" from an observer's name to find t
<ruby>
class MailerObserver < ActiveRecord::Observer
observe :registration, :user
-
+
def after_create(model)
# code to send confirmation email...
end
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 8ccfc8e304..9b3bb1da15 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -348,7 +348,7 @@ That idiom may convey _grouping_ to the reader as well. For example, say you wan
<ruby>
I18n.with_options :locale => user.locale, :scope => "newsletter" do |i18n|
subject i18n.t :subject
- body i18n.t :body, :user_name => user.name
+ body i18n.t :body, :user_name => user.name
end
</ruby>
@@ -762,7 +762,7 @@ class Counter
end
</ruby>
-The method receives the name of an action, and a +:with+ option with code. The code is evaluated in the context of the receiver each time the method is invoked, and it should evaluate to a +Mutex+ instance or any other object that responds to +synchronize+ and accepts a block.
+The method receives the name of an action, and a +:with+ option with code. The code is evaluated in the context of the receiver each time the method is invoked, and it should evaluate to a +Mutex+ instance or any other object that responds to +synchronize+ and accepts a block.
NOTE: Defined in +active_support/core_ext/module/synchronization.rb+.
@@ -1107,7 +1107,7 @@ module ActiveRecord
end
</ruby>
-Since values are copied when a subclass is defined, if the base class changes the attribute after that, the subclass does not see the new value. That's the point.
+Since values are copied when a subclass is defined, if the base class changes the attribute after that, the subclass does not see the new value. That's the point.
NOTE: Defined in +active_support/core_ext/class/inheritable_attributes.rb+.
@@ -1139,7 +1139,7 @@ NOTE: Defined in +active_support/core_ext/class/subclasses.rb+.
h5. +descendants+
-The +descendants+ method returns all classes that are <tt>&lt;</tt> than its receiver:
+The +descendants+ method returns all classes that are <tt>&lt;</tt> than its receiver:
<ruby>
class C; end
@@ -1260,7 +1260,7 @@ Pass a +:separator+ to truncate the string at a natural break:
<ruby>
"Oh dear! Oh dear! I shall be late!".truncate(18)
-# => "Oh dear! Oh dea..."
+# => "Oh dear! Oh dea..."
"Oh dear! Oh dear! I shall be late!".truncate(18, :separator => ' ')
# => "Oh dear! Oh..."
</ruby>
@@ -1751,7 +1751,7 @@ The methods +to_date+, +to_time+, and +to_datetime+ are basically convenience wr
<ruby>
"2010-07-27".to_date # => Tue, 27 Jul 2010
"2010-07-27 23:37:00".to_time # => Tue Jul 27 23:37:00 UTC 2010
-"2010-07-27 23:37:00".to_datetime # => Tue, 27 Jul 2010 23:37:00 +0000
+"2010-07-27 23:37:00".to_datetime # => Tue, 27 Jul 2010 23:37:00 +0000
</ruby>
+to_time+ receives an optional argument +:utc+ or +:local+, to indicate which time zone you want the time in:
@@ -3032,14 +3032,14 @@ h6. +ago+, +since+
The method +ago+ receives a number of seconds as argument and returns a timestamp those many seconds ago from midnight:
<ruby>
-date = Date.current # => Fri, 11 Jun 2010
+date = Date.current # => Fri, 11 Jun 2010
date.ago(1) # => Thu, 10 Jun 2010 23:59:59 EDT -04:00
</ruby>
Similarly, +since+ moves forward:
<ruby>
-date = Date.current # => Fri, 11 Jun 2010
+date = Date.current # => Fri, 11 Jun 2010
date.since(1) # => Fri, 11 Jun 2010 00:00:01 EDT -04:00
</ruby>
diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile
index 8a38cf2dc2..972e7ea840 100644
--- a/railties/guides/source/ajax_on_rails.textile
+++ b/railties/guides/source/ajax_on_rails.textile
@@ -47,7 +47,7 @@ Let's start with the the probably most often used helper: +link_to_remote+, whic
The signature of +link_to_remote+ function is the same as that of the standard +link_to+ helper:
<ruby>
-def link_to_remote(name, options = {}, html_options = nil)
+def link_to_remote(name, options = {}, html_options = nil)
</ruby>
And here is a simple example of link_to_remote in action:
@@ -98,7 +98,7 @@ link_to_remote "Delete the item",
Note that if we wouldn't override the default behavior (POST), the above snippet would route to the create action rather than destroy.
** *JavaScript filters* You can customize the remote call further by wrapping it with some JavaScript code. Let's say in the previous example, when deleting a link, you'd like to ask for a confirmation by showing a simple modal text box to the user. This is a typical example what you can accomplish with these options - let's see them one by one:
-*** +:confirm+ =&gt; +msg+ Pops up a JavaScript confirmation dialog, displaying +msg+. If the user chooses 'OK', the request is launched, otherwise canceled.
+*** +:confirm+ =&gt; +msg+ Pops up a JavaScript confirmation dialog, displaying +msg+. If the user chooses 'OK', the request is launched, otherwise canceled.
*** +:condition+ =&gt; +code+ Evaluates +code+ (which should evaluate to a boolean) and proceeds if it's true, cancels the request otherwise.
*** +:before+ =&gt; +code+ Evaluates the +code+ just before launching the request. The output of the code has no influence on the execution. Typically used show a progress indicator (see this in action in the next example).
*** +:after+ =&gt; +code+ Evaluates the +code+ after launching the request. Note that this is different from the +:success+ or +:complete+ callback (covered in the next section) since those are triggered after the request is completed, while the code snippet passed to +:after+ is evaluated after the remote call is made. A common example is to disable elements on the page or otherwise prevent further action while the request is completed.
@@ -115,8 +115,8 @@ link_to_remote "Update record",
This generates a remote link which adds 2 parameters to the standard URL generated by Rails, taken from the page (contained in the elements matched by the 'status' and 'completed' DOM id).
** *Callbacks* Since an AJAX call is typically asynchronous, as it's name suggests (this is not a rule, and you can fire a synchronous request - see the last option, +:type+) your only way of communicating with a request once it is fired is via specifying callbacks. There are six options at your disposal (in fact 508, counting all possible response types, but these six are the most frequent and therefore specified by a constant):
-*** +:loading:+ =&gt; +code+ The request is in the process of receiving the data, but the transfer is not completed yet.
-*** +:loaded:+ =&gt; +code+ The transfer is completed, but the data is not processed and returned yet
+*** +:loading:+ =&gt; +code+ The request is in the process of receiving the data, but the transfer is not completed yet.
+*** +:loaded:+ =&gt; +code+ The transfer is completed, but the data is not processed and returned yet
*** +:interactive:+ =&gt; +code+ One step after +:loaded+: The data is fully received and being processed
*** +:success:+ =&gt; +code+ The data is fully received, parsed and the server responded with "200 OK"
*** +:failure:+ =&gt; +code+ The data is fully received, parsed and the server responded with *anything* but "200 OK" (typically 404 or 500, but in general with any status code ranging from 100 to 509)
@@ -143,15 +143,15 @@ link_to_remote "Add new item",
** If you specify the +href+ parameter, the AJAX link will degrade gracefully, i.e. the link will point to the URL even if JavaScript is disabled in the client browser
** +link_to_remote+ gains it's AJAX behavior by specifying the remote call in the onclick handler of the link. If you supply +html_options[:onclick]+ you override the default behavior, so use this with care!
-We are finished with +link_to_remote+. I know this is quite a lot to digest for one helper function, but remember, these options are common for all the rest of the Rails view helpers, so we will take a look at the differences / additional parameters in the next sections.
+We are finished with +link_to_remote+. I know this is quite a lot to digest for one helper function, but remember, these options are common for all the rest of the Rails view helpers, so we will take a look at the differences / additional parameters in the next sections.
h4. AJAX Forms
There are three different ways of adding AJAX forms to your view using Rails Prototype helpers. They are slightly different, but striving for the same goal: instead of submitting the form using the standard HTTP request/response cycle, it is submitted asynchronously, thus not reloading the page. These methods are the following:
* +remote_form_for+ (and it's alias +form_remote_for+) is tied to Rails most tightly of the three since it takes a resource, model or array of resources (in case of a nested resource) as a parameter.
-* +form_remote_tag+ AJAXifies the form by serializing and sending it's data in the background
-* +submit_to_remote+ and +button_to_remote+ is more rarely used than the previous two. Rather than creating an AJAX form, you add a button/input
+* +form_remote_tag+ AJAXifies the form by serializing and sending it's data in the background
+* +submit_to_remote+ and +button_to_remote+ is more rarely used than the previous two. Rather than creating an AJAX form, you add a button/input
Let's se them in action one by one!
@@ -161,7 +161,7 @@ h5. +form_remote_tag+
h5. +submit_to_remote+
-h4. Observing Elements
+h4. Observing Elements
h5. +observe_field+
@@ -186,10 +186,10 @@ In the last section we sent some AJAX requests to the server, and inserted the H
h4. Javascript without RJS
First we'll check out how to send JavaScript to the server manually. You are practically never going to need this, but it's interesting to understand what's going on under the hood.
-
+
<ruby>
def javascript_test
- render :text => "alert('Hello, world!')",
+ render :text => "alert('Hello, world!')",
:content_type => "text/javascript"
end
</ruby>
@@ -207,14 +207,14 @@ def javascript_test
render :update do |page|
page.alert "Hello from inline RJS"
end
-end
+end
</ruby>
-The above code snippet does exactly the same as the one in the previous section - going about it much more elegantly though. You don't need to worry about headers,write ugly JavaScript code into a string etc. When the first parameter to +render+ is +:update+, Rails expects a block with a single parameter (+page+ in our case, which is the traditional naming convention) which is an instance of the JavaScriptGenerator:"http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html" object. As it's name suggests, JavaScriptGenerator is responsible for generating JavaScript from your Ruby code. You can execute multiple method calls on the +page+ instance - it's all turned into JavaScript code and sent to the server with the appropriate Content Type, "text/javascript".
+The above code snippet does exactly the same as the one in the previous section - going about it much more elegantly though. You don't need to worry about headers,write ugly JavaScript code into a string etc. When the first parameter to +render+ is +:update+, Rails expects a block with a single parameter (+page+ in our case, which is the traditional naming convention) which is an instance of the JavaScriptGenerator:"http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html" object. As it's name suggests, JavaScriptGenerator is responsible for generating JavaScript from your Ruby code. You can execute multiple method calls on the +page+ instance - it's all turned into JavaScript code and sent to the server with the appropriate Content Type, "text/javascript".
h4. RJS Templates
-If you don't want to clutter your controllers with view code (especially when your inline RJS is more than a few lines), you can move your RJS code to a template file. RJS templates should go to the +/app/views/+ directory, just as +.html.erb+ or any other view files of the appropriate controller, conventionally named +js.rjs+.
+If you don't want to clutter your controllers with view code (especially when your inline RJS is more than a few lines), you can move your RJS code to a template file. RJS templates should go to the +/app/views/+ directory, just as +.html.erb+ or any other view files of the appropriate controller, conventionally named +js.rjs+.
To rewrite the above example, you can leave the body of the action empty, and create a RJS template named +javascript_test.js.rjs+, containing the following line:
@@ -265,7 +265,7 @@ The third parameter can either be a string, or a hash of options to be passed to
page.insert_html :top, :result, :partial => "the_answer"
</ruby>
-You can replace the contents (innerHTML) of an element with the +replace_html+ method. The only difference is that since it's clear where should the new content go, there is no need for a position parameter - so +replace_html+ takes only two arguments,
+You can replace the contents (innerHTML) of an element with the +replace_html+ method. The only difference is that since it's clear where should the new content go, there is no need for a position parameter - so +replace_html+ takes only two arguments,
the DOM id of the element you wish to modify and a string or a hash of options to be passed to ActionView::Base#render.
h6. Delay
@@ -273,7 +273,7 @@ h6. Delay
You can delay the execution of a block of code with +delay+:
<ruby>
-page.delay(10) { page.alert('Hey! Just waited 10 seconds') }
+page.delay(10) { page.alert('Hey! Just waited 10 seconds') }
</ruby>
+delay+ takes one parameter (time to wait in seconds) and a block which will be executed after the specified time has passed - whatever else follows a +page.delay+ line is executed immediately, the delay affects only the code in the block.
@@ -283,7 +283,7 @@ h6. Reloading and Redirecting
You can reload the page with the +reload+ method:
<ruby>
-page.reload
+page.reload
</ruby>
When using AJAX, you can't rely on the standard +redirect_to+ controller method - you have to use the +page+'s instance method, also called +redirect_to+:
@@ -292,7 +292,7 @@ When using AJAX, you can't rely on the standard +redirect_to+ controller method
page.redirect_to some_url
</ruby>
-h6. Generating Arbitrary JavaScript
+h6. Generating Arbitrary JavaScript
Sometimes even the full power of RJS is not enough to accomplish everything, but you still don't want to drop to pure JavaScript. A nice golden mean is offered by the combination of +<<+, +assign+ and +call+ methods:
diff --git a/railties/guides/source/api_documentation_guidelines.textile b/railties/guides/source/api_documentation_guidelines.textile
index 9f201de49b..d2ccb6475e 100644
--- a/railties/guides/source/api_documentation_guidelines.textile
+++ b/railties/guides/source/api_documentation_guidelines.textile
@@ -25,7 +25,7 @@ end
Communicate to the reader the current way of doing things, both explicitly and implicitly. Use the recommended idioms in edge, reorder sections to emphasize favored approaches if needed, etc. The documentation should be a model for best practices and canonical, modern Rails usage.
-Documentation has to be concise but comprehensive. Explore and document edge cases. What happens if a module is anonymous? What if a collection is empty? What if an argument is nil?
+Documentation has to be concise but comprehensive. Explore and document edge cases. What happens if a module is anonymous? What if a collection is empty? What if an argument is nil?
The proper names of Rails components have a space in between the words, like "Active Support". +ActiveRecord+ is a Ruby module, whereas Active Record is an ORM. Historically there has been lack of consistency regarding this, but we checked with David when docrails started. All Rails documentation consistently refer to Rails components by their proper name, and if in your next blog post or presentation you remember this tidbit and take it into account that'd be fenomenal :).
@@ -125,7 +125,7 @@ def copy_instance_variables_from(object, exclude = [])
end
</ruby>
-WARNING: Using a pair of +&#43;...&#43;+ for fixed-width font only works with *words*; that is: anything matching <tt>\A\w&#43;\z</tt>. For anything else use +&lt;tt&gt;...&lt;/tt&gt;+, notably symbols, setters, inline snippets, etc:
+WARNING: Using a pair of +&#43;...&#43;+ for fixed-width font only works with *words*; that is: anything matching <tt>\A\w&#43;\z</tt>. For anything else use +&lt;tt&gt;...&lt;/tt&gt;+, notably symbols, setters, inline snippets, etc:
h4. Regular Font
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile
index fd1e7f4baf..079bb4b6b2 100644
--- a/railties/guides/source/association_basics.textile
+++ b/railties/guides/source/association_basics.textile
@@ -1401,8 +1401,8 @@ person = Person.create(:name => 'honda')
post = Post.create(:name => 'a1')
person.posts << post
person.posts << post
-person.posts.inspect # => [#<Post id: 7, name: "a1">]
-Reading.all.inspect # => [#<Reading id: 16, person_id: 7, post_id: 7>, #<Reading id: 17, person_id: 7, post_id: 7>]
+person.posts.inspect # => [#<Post id: 7, name: "a1">]
+Reading.all.inspect # => [#<Reading id: 16, person_id: 7, post_id: 7>, #<Reading id: 17, person_id: 7, post_id: 7>]
</ruby>
In the above case there are still two readings. However +person.posts+ shows only one post because the collection loads only unique records.
diff --git a/railties/guides/source/caching_with_rails.textile b/railties/guides/source/caching_with_rails.textile
index 6dee4b9c61..ff672d8695 100644
--- a/railties/guides/source/caching_with_rails.textile
+++ b/railties/guides/source/caching_with_rails.textile
@@ -98,7 +98,7 @@ You can also use +:if+ (or +:unless+) to pass a Proc that specifies when the act
You can modify the default action cache path by passing a +:cache_path+ option. This will be passed directly to +ActionCachePath.path_for+. This is handy for actions with multiple possible routes that should be cached differently. If a block is given, it is called with the current controller instance.
-Finally, if you are using memcached, you can also pass +:expires_in+. In fact, all parameters not used by +caches_action+ are sent to the underlying cache store.
+Finally, if you are using memcached, you can also pass +:expires_in+. In fact, all parameters not used by +caches_action+ are sent to the underlying cache store.
INFO: Action caching runs in an after filter. Thus, invalid requests won't generate spurious cache entries as long as you halt them. Typically, a redirection in some before filter that checks request preconditions does the job.
@@ -242,12 +242,12 @@ Rails 2.1 and above provide +ActiveSupport::Cache::Store+ which can be used to c
The default cache stores provided with Rails include:
-1) +ActiveSupport::Cache::MemoryStore+: A cache store implementation which stores everything into memory in the same process. If you're running multiple Ruby on Rails server processes (which is the case if you're using mongrel_cluster or Phusion Passenger), then this means that your Rails server process instances won't be able to share cache data with each other. If your application never performs manual cache item expiry (e.g. when you‘re using generational cache keys), then using +MemoryStore+ is ok. Otherwise, consider carefully whether you should be using this cache store.
+1) +ActiveSupport::Cache::MemoryStore+: A cache store implementation which stores everything into memory in the same process. If you're running multiple Ruby on Rails server processes (which is the case if you're using mongrel_cluster or Phusion Passenger), then this means that your Rails server process instances won't be able to share cache data with each other. If your application never performs manual cache item expiry (e.g. when you‘re using generational cache keys), then using +MemoryStore+ is ok. Otherwise, consider carefully whether you should be using this cache store.
+MemoryStore+ is not only able to store strings, but also arbitrary Ruby objects.
+MemoryStore+ is not thread-safe. Use +SynchronizedMemoryStore+ instead if you need thread-safety.
-
+
<ruby>
ActionController::Base.cache_store = :memory_store
</ruby>
@@ -280,7 +280,7 @@ It also accepts a hash of additional options:
The read and write methods of the +MemCacheStore+ accept an options hash too. When reading you can specify +:raw => true+ to prevent the object being marshaled (by default this is false which means the raw value in the cache is passed to +Marshal.load+ before being returned to you.)
-When writing to the cache it is also possible to specify +:raw => true+ means the value is not passed to +Marshal.dump+ before being stored in the cache (by default this is false).
+When writing to the cache it is also possible to specify +:raw => true+ means the value is not passed to +Marshal.dump+ before being stored in the cache (by default this is false).
The write method also accepts an +:unless_exist+ flag which determines whether the memcached add (when true) or set (when false) method is used to store the item in the cache and an +:expires_in+ option that specifies the time-to-live for the cached item in seconds.
@@ -367,7 +367,7 @@ h3. Advanced Caching
Along with the built-in mechanisms outlined above, a number of excellent plugins exist to help with finer grained control over caching. These include Chris Wanstrath's excellent cache_fu plugin (more info "here": http://errtheblog.com/posts/57-kickin-ass-w-cachefu) and Evan Weaver's interlock plugin (more info "here": http://blog.evanweaver.com/articles/2007/12/13/better-rails-caching/). Both of these plugins play nice with memcached and are a must-see for anyone
seriously considering optimizing their caching needs.
-Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plugin is supposed to be mad cool.
+Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plugin is supposed to be mad cool.
h3. References
diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile
index fb625f7a44..cbdfda9215 100644
--- a/railties/guides/source/command_line.textile
+++ b/railties/guides/source/command_line.textile
@@ -35,7 +35,7 @@ WARNING: You know you need the rails gem installed by typing +gem install rails+
<shell>
$ rails new commandsapp
- create
+ create
create README
create .gitignore
create Rakefile
@@ -570,7 +570,7 @@ h5. +test:+ Rails tests
INFO: A good description of unit testing in Rails is given in "A Guide to Testing Rails Applications":testing.html
-Rails comes with a test suite called Test::Unit. It is through the use of tests that Rails itself is so stable, and the slew of people working on Rails can prove that everything works as it should.
+Rails comes with a test suite called Test::Unit. It is through the use of tests that Rails itself is so stable, and the slew of people working on Rails can prove that everything works as it should.
The +test:+ namespace helps in running the different tests you will (hopefully!) write.
diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile
index 9e0c7cd060..81ef910822 100644
--- a/railties/guides/source/configuring.textile
+++ b/railties/guides/source/configuring.textile
@@ -51,15 +51,15 @@ h4. Rails General Configuration
* +config.dependency_loading+ enables or disables dependency loading during the request cycle. Setting dependency_loading to _true_ will allow new classes to be loaded during a request and setting it to _false_ will disable this behavior.
-* +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+.
+* +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+.
* +config.load_once_paths+ accepts an array of paths from which Rails will automatically load from only once. All elements of this array must also be in +load_paths+.
-* +config.load_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list.
+* +config.load_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list.
-* +config.log_level+ defines the verbosity of the Rails logger. In production mode, this defaults to +:info+. In development mode, it defaults to +:debug+.
+* +config.log_level+ defines the verbosity of the Rails logger. In production mode, this defaults to +:info+. In development mode, it defaults to +:debug+.
-* +config.log_path+ overrides the path to the log file to use. Defaults to +log/#{environment}.log+ (e.g. log/development.log or log/production.log).
+* +config.log_path+ overrides the path to the log file to use. Defaults to +log/#{environment}.log+ (e.g. log/development.log or log/production.log).
* +config.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging.
@@ -73,7 +73,7 @@ h4. Rails General Configuration
* +config.preload_frameworks+ enables or disables preloading all frameworks at startup.
-* +config.reload_plugins+ enables or disables plugin reloading.
+* +config.reload_plugins+ enables or disables plugin reloading.
* +config.root_path+ configures the root path of the application.
diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile
index ffb0310816..270fbe76d2 100644
--- a/railties/guides/source/getting_started.textile
+++ b/railties/guides/source/getting_started.textile
@@ -475,13 +475,13 @@ After the console loads, you can use it to work with your application's models:
<shell>
>> p = Post.new(:content => "A new post")
-=> #<Post id: nil, name: nil, title: nil,
+=> #<Post id: nil, name: nil, title: nil,
content: "A new post", created_at: nil,
updated_at: nil>
>> p.save
=> false
>> p.errors
-=> #<OrderedHash { :title=>["can't be blank",
+=> #<OrderedHash { :title=>["can't be blank",
"is too short (minimum is 5 characters)"],
:name=>["can't be blank"] }>
</shell>
@@ -742,7 +742,7 @@ def update
respond_to do |format|
if @post.update_attributes(params[:post])
- format.html { redirect_to(@post,
+ format.html { redirect_to(@post,
:notice => 'Post was successfully updated.') }
format.xml { head :ok }
else
@@ -1056,7 +1056,7 @@ Then in the +app/views/posts/show.html.erb+ you can change it to look like the f
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
@@ -1127,7 +1127,7 @@ Then you make the +app/views/posts/show.html.erb+ look like the following:
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
@@ -1213,15 +1213,15 @@ Rails provides a very simple HTTP authentication system that will work nicely in
<ruby>
class ApplicationController < ActionController::Base
protect_from_forgery
-
+
private
-
+
def authenticate
authenticate_or_request_with_http_basic do |user_name, password|
user_name == 'admin' && password == 'password'
end
end
-
+
end
</ruby>
@@ -1381,7 +1381,7 @@ Finally, we will edit the <tt>app/views/posts/show.html.erb</tt> template to sho
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
@@ -1405,7 +1405,7 @@ Open up <tt>app/helpers/posts_helper.rb</tt> and add the following:
<erb>
module PostsHelper
def join_tags(post)
- post.tags.map { |t| t.name }.join(", ")
+ post.tags.map { |t| t.name }.join(", ")
end
end
</erb>
@@ -1436,7 +1436,7 @@ Now you can edit the view in <tt>app/views/posts/show.html.erb</tt> to look like
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile
index 63d22db485..1af51af80e 100644
--- a/railties/guides/source/i18n.textile
+++ b/railties/guides/source/i18n.textile
@@ -518,7 +518,7 @@ es:
title: "Título"
</yaml>
-you can look up the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot):
+you can look up the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot):
<ruby>
<%= t '.title' %>
diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile
index f80c00b280..4e257d2e00 100644
--- a/railties/guides/source/initialization.textile
+++ b/railties/guides/source/initialization.textile
@@ -229,7 +229,7 @@ This file goes on to define some classes that will be automatically loaded using
<ruby>
require "active_support/inflector/methods"
require "active_support/lazy_load_hooks"
-
+
module ActiveSupport
module Autoload
def self.extended(base)
@@ -250,7 +250,7 @@ This file goes on to define some classes that will be automatically loaded using
end
super const_name, location
end
-
+
...
end
end
@@ -337,7 +337,7 @@ As you can see for the duration of the +eager_autoload+ block the class variable
autoload :I18n, "active_support/i18n"
</ruby>
-So we know the ones in +eager_autoload+ are eagerly loaded and it does this by storing them in an +@@autoloads+ hash object and then loading them via +eager_autoload!+ which is called via the +preload_frameworks+ initializer defined in _railties/lib/rails/application/bootstrap.rb_.
+So we know the ones in +eager_autoload+ are eagerly loaded and it does this by storing them in an +@@autoloads+ hash object and then loading them via +eager_autoload!+ which is called via the +preload_frameworks+ initializer defined in _railties/lib/rails/application/bootstrap.rb_.
The classes and modules that are not +eager_autoload+'d are automatically loaded as they are references
@@ -423,16 +423,16 @@ Now that Rails has required Action Dispatch and it has required Rack, Rails can
<ruby>
module Rails
class Server < ::Rack::Server
-
+
...
-
+
def initialize(*)
super
set_environment
end
-
+
...
-
+
def set_environment
ENV["RAILS_ENV"] ||= options[:environment]
end
@@ -486,7 +486,7 @@ And +default_options+ like this:
:AccessLog => [],
:config => "config.ru"
}
- end
+ end
</ruby>
Here it is important to note that the default environment is _development_. After +Rack::Server#initialize+ has done its thing it returns to +Rails::Server#initialize+ which calls +set_environment+:
@@ -752,7 +752,7 @@ If you wish to know more about how they're deprecated see the +require 'active_s
h4. +require 'rails/log_subscriber'+
-The +Rails::LogSubscriber+ provides a central location for logging in Rails 3 so as to not slow down the main thread. When you call one of the logging methods (+info+, +debug+, +warn+, +error+, +fatal+ or +unknown+) from the +Rails::LogSubscriber+ class or one of its subclasses this will notify the Rails logger to log this call in the fashion you specify, but will not write it to the file. The file writing is done at the end of the request, courtesy of the +Rails::Rack::Logger+ middleware.
+The +Rails::LogSubscriber+ provides a central location for logging in Rails 3 so as to not slow down the main thread. When you call one of the logging methods (+info+, +debug+, +warn+, +error+, +fatal+ or +unknown+) from the +Rails::LogSubscriber+ class or one of its subclasses this will notify the Rails logger to log this call in the fashion you specify, but will not write it to the file. The file writing is done at the end of the request, courtesy of the +Rails::Rack::Logger+ middleware.
Each Railtie defines its own class that descends from +Rails::LogSubscriber+ with each defining its own methods for logging individual tasks.
@@ -821,7 +821,7 @@ TODO: Quotify.
<plain>
Active Record connects business objects and database tables to create a persistable domain model where logic and data are presented in one wrapping. It's an implementation of the object-relational mapping (ORM) pattern by the same name as described by Martin Fowler:
- "An object that wraps a row in a database table or view, encapsulates
+ "An object that wraps a row in a database table or view, encapsulates
the database access, and adds domain logic on that data."
Active Record's main contribution to the pattern is to relieve the original of two stunting problems:
@@ -910,7 +910,7 @@ h5. +require 'active_record'+
Back the initial require from the _railtie.rb_.
-The _active_support_ and _active_model_ requires are again just an insurance for if we're loading Active Record outside of the scope of Rails. In _active_record.rb_ the ActiveRecord +Module+ is initialized and in it there is defined a couple of +autoloads+ and +eager_autoloads+.
+The _active_support_ and _active_model_ requires are again just an insurance for if we're loading Active Record outside of the scope of Rails. In _active_record.rb_ the ActiveRecord +Module+ is initialized and in it there is defined a couple of +autoloads+ and +eager_autoloads+.
There's a new method here called +autoload_under+ which is defined in +ActiveSupport::Autoload+. This sets the autoload path to temporarily be the specified path, in this case +relation+ for the +autoload+'d classes inside the block.
@@ -935,7 +935,7 @@ Inside the Active Record Railtie the +ActiveRecord::Railtie+ class is defined:
<ruby>
module ActiveRecord
class Railtie < Rails::Railtie
-
+
...
end
end
@@ -964,8 +964,8 @@ This Railtie is +require+'d by Active Record's Railtie.
From the Active Model readme:
<plain>
- Prior to Rails 3.0, if a plugin or gem developer wanted to be able to have an object interact with Action Pack helpers, it was required to either copy chunks of code from Rails, or monkey patch entire helpers to make them handle objects that did not look like Active Record. This generated code duplication and fragile applications that broke on upgrades.
-
+ Prior to Rails 3.0, if a plugin or gem developer wanted to be able to have an object interact with Action Pack helpers, it was required to either copy chunks of code from Rails, or monkey patch entire helpers to make them handle objects that did not look like Active Record. This generated code duplication and fragile applications that broke on upgrades.
+
Active Model is a solution for this problem.
Active Model provides a known set of interfaces that your objects can implement to then present a common interface to the Action Pack helpers.
@@ -999,7 +999,7 @@ This first makes a couple of requires:
require "action_view/railtie"
</ruby>
-The _action_controller_ file is explained in the very next section. The require to _rails_ is requiring the already-required _railties/lib/rails.rb_. If you wish to know about the require to _action_view/railtie_ this is explained in the Action View Railtie section.
+The _action_controller_ file is explained in the very next section. The require to _rails_ is requiring the already-required _railties/lib/rails.rb_. If you wish to know about the require to _action_view/railtie_ this is explained in the Action View Railtie section.
h5. +require 'action_controller+
@@ -1009,7 +1009,7 @@ h5. +require 'abstract_controller'+
+AbstractController+ provides the functionality of TODO.
-This file is in _actionpack/lib/abstract_controller.rb_ and begins by attempting to add the path to Active Support to the load path, which it would succeed in if it wasn't already set by anything loaded before it. In this case, it's not going to be set due to Arel already loading it in (TODO: right?).
+This file is in _actionpack/lib/abstract_controller.rb_ and begins by attempting to add the path to Active Support to the load path, which it would succeed in if it wasn't already set by anything loaded before it. In this case, it's not going to be set due to Arel already loading it in (TODO: right?).
The next thing in this file four +require+ calls:
@@ -1146,9 +1146,9 @@ For an explanation of this file _activesupport/lib/active_support/core_ext/class
h5. +require 'active_support/deprecation/proxy_wrappers'+
-This file, _activesupport/lib/active_support/deprecation/proxy_wrappers.rb_, defines a couple of deprecation classes, which are +DeprecationProxy+, +DeprecationObjectProxy+, +DeprecationInstanceVariableProxy+, +DeprecationConstantProxy+ which are all namespaced into +ActiveSupport::Deprecation+. These last three are all subclasses of +DeprecationProxy+.
+This file, _activesupport/lib/active_support/deprecation/proxy_wrappers.rb_, defines a couple of deprecation classes, which are +DeprecationProxy+, +DeprecationObjectProxy+, +DeprecationInstanceVariableProxy+, +DeprecationConstantProxy+ which are all namespaced into +ActiveSupport::Deprecation+. These last three are all subclasses of +DeprecationProxy+.
-Why do we mention them here? Beside the obvious-by-now fact that we're covering just about everything about the initialization process in this guide, if you're deprecating something in your library and you use Active Support, you too can use the +DeprecationProxy+ class (and it's subclasses) too.
+Why do we mention them here? Beside the obvious-by-now fact that we're covering just about everything about the initialization process in this guide, if you're deprecating something in your library and you use Active Support, you too can use the +DeprecationProxy+ class (and it's subclasses) too.
h6. +DeprecationProxy+
@@ -1177,7 +1177,7 @@ This class is used only in _railties/lib/rails/deprecation.rb_, loaded further o
end).new
</ruby>
-There is similar definitions for the other constants of +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+. All three of these constants are in the midst of being deprecated (most likely in Rails 3.1) so Rails will tell you if you reference them that they're deprecated using the +DeprecationProxy+ class. Whenever you call +RAILS_ROOT+ this will raise a warning, telling you: "RAILS_ROOT is deprecated! Use Rails.root instead".... TODO: investigate if simply calling it does raise this warning. This same rule applies to +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+, their new alternatives are +Rails.env+ and +Rails.logger+ respectively.
+There is similar definitions for the other constants of +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+. All three of these constants are in the midst of being deprecated (most likely in Rails 3.1) so Rails will tell you if you reference them that they're deprecated using the +DeprecationProxy+ class. Whenever you call +RAILS_ROOT+ this will raise a warning, telling you: "RAILS_ROOT is deprecated! Use Rails.root instead".... TODO: investigate if simply calling it does raise this warning. This same rule applies to +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+, their new alternatives are +Rails.env+ and +Rails.logger+ respectively.
h6. +DeprecatedObjectProxy+
@@ -1203,7 +1203,7 @@ This makes more sense in the wider scope of the initializer:
end
</ruby>
-+ActionController::Routing::Routes+ was the previous constant used in defining routes in Rails 2 applications, now it's simply a method on +Rails.application+ rather than it's own individual class: +Rails.application.routes+. Both of these still call the +draw+ method on the returned object to end up defining the routes.
++ActionController::Routing::Routes+ was the previous constant used in defining routes in Rails 2 applications, now it's simply a method on +Rails.application+ rather than it's own individual class: +Rails.application.routes+. Both of these still call the +draw+ method on the returned object to end up defining the routes.
h6. +DeprecatedInstanceVariableProxy+
@@ -1362,7 +1362,7 @@ Here again we have the addition of the path to Active Support to the load path a
And these have already been required. If you wish to know what these files do go to the explanation of each in the "Common Includes" section. TODO: link to them!
-This file goes on to +require 'action_pack'+ which consists of all this code (comments stripped):
+This file goes on to +require 'action_pack'+ which consists of all this code (comments stripped):
<ruby>
require 'action_pack/version'
@@ -1445,11 +1445,11 @@ After including +ActiveSupport::Benchmarkable+, the helpers which we have declar
h5. +ActionView::Rendering+
-This module, from _actionpack/lib/action_view/render/rendering.rb_ defines a method you may be a little too familiar with: +render+. This is the +render+ use for rendering all kinds of things, such as partials, templates and text.
+This module, from _actionpack/lib/action_view/render/rendering.rb_ defines a method you may be a little too familiar with: +render+. This is the +render+ use for rendering all kinds of things, such as partials, templates and text.
h5. +ActionView::Partials+
-This module, from _actionpack/lib/action_view/render/partials.rb_, defines +ActionView::Partials::PartialRenderer+ which you can probably guess is used for rendering partials.
+This module, from _actionpack/lib/action_view/render/partials.rb_, defines +ActionView::Partials::PartialRenderer+ which you can probably guess is used for rendering partials.
h5. +ActionView::Layouts+
@@ -1487,7 +1487,7 @@ Next, the Railtie itself is defined:
end
end
end
-</ruby>
+</ruby>
The +ActionView::LogSubscriber+ sets up a method called +render_template+ which is called when a template is rendered. TODO: Templates only or partials and layouts also? I would imagine these fall under the templates category, but there needs to research to ensure this is correct.
@@ -1502,7 +1502,7 @@ are used to consolidate code for sending out forgotten passwords, welcome
wishes on signup, invoices for billing, and any other use case that requires
a written notification to either a person or another system.
-Action Mailer is in essence a wrapper around Action Controller and the
+Action Mailer is in essence a wrapper around Action Controller and the
Mail gem. It provides a way to make emails using templates in the same
way that Action Controller renders views using templates.
@@ -1580,7 +1580,7 @@ which is used by the +ActionMailer::MailerHelper+ method +block_format+:
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
).format
}.join("\n")
-
+
# Make list points stand on their own line
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }
@@ -1687,7 +1687,7 @@ There is only one initializer defined here: +set_configs+. This is covered later
h4. ActionDispatch Railtie
-ActionDispatch handles all dispatch work for Rails. It interfaces with Action Controller to determine what action to undertake when a request comes in. TODO: I would quote the README but it is strangely absent. Flyin' blind here!
+ActionDispatch handles all dispatch work for Rails. It interfaces with Action Controller to determine what action to undertake when a request comes in. TODO: I would quote the README but it is strangely absent. Flyin' blind here!
The ActionDispatch Railtie was previously required when we called +require 'rails'+, but we will cover the Railtie here too.
@@ -1817,7 +1817,7 @@ This +called_from+ setting looks a little overwhelming to begin with, but the sh
base.send(:include, self::Configurable)
subclasses << base
end
- end
+ end
</ruby>
Again, +YourApp::Application+ will return false for +abstract_railtie+ and so the code inside the +unless+ will be ran. The first line:
@@ -1886,7 +1886,7 @@ Now that we've covered the boot process of Rails the next line best to cover wou
Rails::Server.start
</ruby>
-The keen-eyed observer will note that this +when+ also specifies the argument could also be simply +'s'+ thereby making the full command +rails s+. This is the same with the other commands with +generate+ becoming +g+, +console+ becoming +c+ and +dbconsole+ becoming +db+.
+The keen-eyed observer will note that this +when+ also specifies the argument could also be simply +'s'+ thereby making the full command +rails s+. This is the same with the other commands with +generate+ becoming +g+, +console+ becoming +c+ and +dbconsole+ becoming +db+.
This code here ensures we are at the +ROOT_PATH+ of our application (this constant was defined in _script/rails_) and then calls +Rails::Server.start+. +Rails::Server+ descends from +Rack::Server+ which is defined in the rack gem. The +Rails::Server.start+ method is defined like this:
@@ -1997,7 +1997,7 @@ Finally! We've arrived at +default_options+ which leads into our next point quit
end
</ruby>
-We're not debugging anything, so there goes the first 7 lines, we're not warning, nor are we including, requiring, daemonising or writing out a pid file. That's everything except the final line, which calls +run+ with the +wrapped_app+ which is then defined like this:
+We're not debugging anything, so there goes the first 7 lines, we're not warning, nor are we including, requiring, daemonising or writing out a pid file. That's everything except the final line, which calls +run+ with the +wrapped_app+ which is then defined like this:
<ruby>
def wrapped_app
@@ -2051,7 +2051,7 @@ First this reads your config file and checks it for +#\+ at the beginning. This
require ::File.expand_path('../config/environment', __FILE__)
run YourApp::Application.instance
-
+
</ruby>
TODO: Is the above correct? I am simply guessing!
@@ -2246,7 +2246,7 @@ The method +find_with_root_flag+ is defined on +Rails::Engine+ (the superclass o
Pathname.new(root).expand_path : Pathname.new(root).realpath
end
</ruby>
-
+
+called_from+ goes through the +caller+ which is the stacktrace of the current thread, in the case of your application it would go a little like this:
<pre>
@@ -2274,7 +2274,7 @@ The method +find_with_root_flag+ is defined on +Rails::Engine+ (the superclass o
end
</ruby>
-The +call_stack+ here is the +caller+ output shown previously, minus everything after the first +:+ on all the lines. The first path that matches this is _/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta1/lib/rails_. Yours may vary slightly, but should always end in _railties-x.x.x/lib/rails_.
+The +call_stack+ here is the +caller+ output shown previously, minus everything after the first +:+ on all the lines. The first path that matches this is _/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta1/lib/rails_. Yours may vary slightly, but should always end in _railties-x.x.x/lib/rails_.
The code in +find_root_with_flag+ will go up this directory structure until it reaches the top, which in this case is +/+.
@@ -2302,7 +2302,7 @@ At the root of the system it looks for +config.ru+. TODO: Why? Obviously it's no
@serve_static_assets = true
@time_zone = "UTC"
@consider_all_requests_local = true
- end
+ end
</ruby>
The +super+ method here is the +initialize+ method in +Rails::Engine::Configuration+:
@@ -2604,7 +2604,7 @@ The +plugins+ method it calls is a little more complex:
</ruby>
When we call +@config.paths.vendor.plugins+ it will return +"vendor/plugins"+.
-
+
If you've defined specific plugin requirements for your application in _config/application.rb_ by using this code:
@@ -2725,7 +2725,7 @@ Now we finally have all the +initializers+ we can go through them and call +run+
end
</ruby>
-You may remember that the +@context+ in this code is +YourApp::Application+ and calling +instance_exec+ on this class will make a new instance of it and execute the code within the +&block+ passed to it. This code within the block is the code from all the initializers.
+You may remember that the +@context+ in this code is +YourApp::Application+ and calling +instance_exec+ on this class will make a new instance of it and execute the code within the +&block+ passed to it. This code within the block is the code from all the initializers.
h3. Bootstrap Initializers
@@ -2759,15 +2759,15 @@ We've seen +config.paths+ before when loading the plugins and they're explained
<ruby>
module Rails
class << self
-
+
...
-
+
def env
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end
-
+
...
-
+
end
end
</ruby>
@@ -2953,7 +2953,7 @@ This is where it gets loaded. The +eager_autoload!+ method is defined like this:
end
</ruby>
-With +@@autoloads+ being
+With +@@autoloads+ being
* load_all_active_support
@@ -3144,9 +3144,9 @@ h4. +ActionDispatch::MiddlewareStack.new+
<ruby>
module ActionDispatch
class MiddlewareStack < Array
-
+
...
-
+
def initialize(*args, &block)
super(*args)
block.call(self) if block_given?
@@ -3188,9 +3188,9 @@ This +initialize+ method also is in a class who's ancestry is important so once
<ruby>
module ActionController
class Middleware < Metal
-
+
...
-
+
def initialize(app)
super()
@_app = app
@@ -3207,9 +3207,9 @@ This is another subclassed class, this time from +ActionController::AbstractCont
<ruby>
class Metal < AbstractController::Base
-
+
...
-
+
def initialize(*)
@_headers = {}
super
@@ -3217,7 +3217,7 @@ This is another subclassed class, this time from +ActionController::AbstractCont
end
</ruby>
-The single +*+ in the argument listing means we can accept any number of arguments, we just don't care what they are.
+The single +*+ in the argument listing means we can accept any number of arguments, we just don't care what they are.
h4. +AbstractController::Base.initialize+
@@ -3232,7 +3232,7 @@ This may be anti-climatic, but the initialize method here just returns an +Abstr
h4. +ActionDispatch::MiddlewareStack.use+
-Now we're back to this method, from our foray into the depths of how +Middleware.new+ works, we've showed that it is an instance of +AbstractController::Base+. Therefore it does
+Now we're back to this method, from our foray into the depths of how +Middleware.new+ works, we've showed that it is an instance of +AbstractController::Base+. Therefore it does
TODO: ELABORATE ON THIS SECTION, including explaining what all the pieces of middleware do. Then explain how the default_middleware_stack does what it does, whatever that is.
@@ -3309,7 +3309,7 @@ In a standard Rails application we have this in our _config/environments/develop
end
</ruby>
-It's a little bit sneaky here, but +configure+ is +alias+'d to +class_eval+ on subclasses of +Rails::Application+ which of course includes +YourApp::Application+. This means that the code inside the +configure do+ block will be evaled within the context of +YourApp::Application+. The +config+ method here is the one mentioned before: the +Rails::Application::Configuration+ object. The methods on it should look familiar too: they're the ones that had +attr_accessor+ and +attr_writer+ definitions.
+It's a little bit sneaky here, but +configure+ is +alias+'d to +class_eval+ on subclasses of +Rails::Application+ which of course includes +YourApp::Application+. This means that the code inside the +configure do+ block will be evaled within the context of +YourApp::Application+. The +config+ method here is the one mentioned before: the +Rails::Application::Configuration+ object. The methods on it should look familiar too: they're the ones that had +attr_accessor+ and +attr_writer+ definitions.
The ones down the bottom, +config.action_controller+, +config.action_view+ and +config.action_mailer+ aren't defined by +attr_accessor+ or +attr_writer+, rather they're undefined methods and therefore will trigger the +method_missing+ on the +Rails::Application::Configuration+ option.
@@ -3381,7 +3381,7 @@ I'm going to show you two methods since the third one, +self.plugin_name+, calls
@plugins ||= []
@plugins << klass unless klass == Plugin
end
-
+
def self.plugins
@plugins
end
@@ -3472,7 +3472,7 @@ h5. +Rack::Handler::WEBrick+
This class is subclassed from +WEBrick::HTTPServlet::AbstractServlet+ which is a class that comes with the Ruby standard library. This is the magical class that serves the requests and deals with the comings (requests) and goings (responses) for your server.
-+Rack::Server+ has handlers for the request and by default the handler for a _rails server_ server is
++Rack::Server+ has handlers for the request and by default the handler for a _rails server_ server is
h3. Cruft!
@@ -3706,7 +3706,7 @@ This file is _activesupport/lib/active_support/inflector.rb_ and makes a couple
require 'active_support/core_ext/string/inflections'
</ruby>
-The files included here define methods for modifying strings, such as +transliterate+ which will convert a Unicode string to its ASCII version, +parameterize+ for making strings into url-safe versions, +camelize+ for camel-casing a string such as +string_other+ into +StringOther+ and +ordinalize+ converting a string such as +101+ into +101st+. More information about these methods can be found in the Active Support Core Extensions Guide. TODO: Link to AS Guide.
+The files included here define methods for modifying strings, such as +transliterate+ which will convert a Unicode string to its ASCII version, +parameterize+ for making strings into url-safe versions, +camelize+ for camel-casing a string such as +string_other+ into +StringOther+ and +ordinalize+ converting a string such as +101+ into +101st+. More information about these methods can be found in the Active Support Core Extensions Guide. TODO: Link to AS Guide.
h4. +require 'active_support/core_ext/module/delegation'+
@@ -3715,7 +3715,7 @@ _activesupport/lib/active_support/core_ext/module/delegation.rb_ defines the +de
<ruby>
class Client < ActiveRecord::Base
has_one :address
-
+
delegate :address_line_1, :to => :address
end
</ruby>
@@ -3736,7 +3736,7 @@ h4. +require 'active_support/core_ext/class/attribute_accessors'+
The file, _activesupport/lib/active_support/core_ext/class/attribute_accessors.rb_, defines the class accessor methods +cattr_writer+, +cattr_reader+ and +cattr_accessor+. +cattr_accessor+ defines a +cattr_reader+ and +cattr_writer+ for the symbol passed in. These methods work by defining class variables when you call their dynamic methods.
-Throughout the Railties there a couple of common includes. They are listed here for your convenience.
+Throughout the Railties there a couple of common includes. They are listed here for your convenience.
h4. +require 'active_support/core_ext/module/attr_internal+
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index b9a201e5f0..fe5b4c8773 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -143,7 +143,7 @@ def update
end
</ruby>
-If the call to +update_attributes+ fails, calling the +update+ action in this controller will render the +edit.html.erb+ template belonging to the same controller.
+If the call to +update_attributes+ fails, calling the +update+ action in this controller will render the +edit.html.erb+ template belonging to the same controller.
If you prefer, you can use a symbol instead of a string to specify the action to render:
@@ -200,7 +200,7 @@ render "/u/apps/warehouse_app/current/app/views/products/show"
Rails determines that this is a file render because of the leading slash character. To be explicit, you can use the +:file+ option (which was required on Rails 2.2 and earlier):
<ruby>
-render :file =>
+render :file =>
"/u/apps/warehouse_app/current/app/views/products/show"
</ruby>
@@ -240,7 +240,7 @@ h5. Using +render+ with +:inline+
The +render+ method can do without a view completely, if you're willing to use the +:inline+ option to supply ERB as part of the method call. This is perfectly valid:
<ruby>
-render :inline =>
+render :inline =>
"<% products.each do |p| %><p><%= p.name %><p><% end %>"
</ruby>
@@ -249,7 +249,7 @@ WARNING: There is seldom any good reason to use this option. Mixing ERB into you
By default, inline rendering uses ERb. You can force it to use Builder instead with the +:type+ option:
<ruby>
-render :inline =>
+render :inline =>
"xml.p {'Horrid coding practice!'}", :type => :builder
</ruby>
@@ -676,7 +676,7 @@ h5. Linking to Feeds with +auto_discovery_link_tag+
The +auto_discovery_link_tag+ helper builds HTML that most browsers and newsreaders can use to detect the presences of RSS or ATOM feeds. It takes the type of the link (+:rss+ or +:atom+), a hash of options that are passed through to url_for, and a hash of options for the tag:
<erb>
-<%= auto_discovery_link_tag(:rss, {:action => "feed"},
+<%= auto_discovery_link_tag(:rss, {:action => "feed"},
{:title => "RSS Feed"}) %>
</erb>
@@ -739,7 +739,7 @@ If you're loading multiple javascript files, you can create a better user experi
By default, the combined file will be delivered as +javascripts/all.js+. You can specify a location for the cached asset file instead:
<erb>
-<%= javascript_include_tag "main", "columns",
+<%= javascript_include_tag "main", "columns",
:cache => 'cache/main/display' %>
</erb>
@@ -798,7 +798,7 @@ If you're loading multiple CSS files, you can create a better user experience by
By default, the combined file will be delivered as +stylesheets/all.css+. You can specify a location for the cached asset file instead:
<erb>
-<%= stylesheet_link_tag "main", "columns",
+<%= stylesheet_link_tag "main", "columns",
:cache => 'cache/main/display' %>
</erb>
@@ -1085,7 +1085,7 @@ Partials are very useful in rendering collections. When you pass a collection to
<p>Product Name: <%= product.name %></p>
</erb>
-When a partial is called with a pluralized collection, then the individual instances of the partial have access to the member of the collection being rendered via a variable named after the partial. In this case, the partial is +_product+, and within the +_product+ partial, you can refer to +product+ to get the instance that is being rendered.
+When a partial is called with a pluralized collection, then the individual instances of the partial have access to the member of the collection being rendered via a variable named after the partial. In this case, the partial is +_product+, and within the +_product+ partial, you can refer to +product+ to get the instance that is being rendered.
In Rails 3.0 there is also a shorthand for this, assuming +@posts+ is a collection of +post+ instances, you can simply do in the +index.html.erb+:
@@ -1132,7 +1132,7 @@ With this change, you can access an instance of the +@products+ collection as th
You can also pass in arbitrary local variables to any partial you are rendering with the +:locals => {}+ option:
<erb>
-<%= render :partial => 'products', :collection => @products,
+<%= render :partial => 'products', :collection => @products,
:as => :item, :locals => {:title => "Products Page"} %>
</erb>
diff --git a/railties/guides/source/nested_model_forms.textile b/railties/guides/source/nested_model_forms.textile
index 39b0c32f24..1d44da4df1 100644
--- a/railties/guides/source/nested_model_forms.textile
+++ b/railties/guides/source/nested_model_forms.textile
@@ -63,7 +63,7 @@ class Person
def address
Address.new
end
-
+
def address_attributes=(attributes)
# ...
end
@@ -77,7 +77,7 @@ class Person
def projects
[Project.new, Project.new]
end
-
+
def projects_attributes=(attributes)
# ...
end
@@ -101,7 +101,7 @@ class PeopleController < ActionController:Base
@person.built_address
2.times { @person.projects.build }
end
-
+
def create
@person = Person.new(params[:person])
if @person.save
@@ -142,7 +142,7 @@ Now add a nested form for the +address+ association:
<erb>
<%= form_for @person do |f| %>
<%= f.text_field :name %>
-
+
<%= f.fields_for :address do |af| %>
<%= f.text_field :street %>
<% end %>
@@ -154,7 +154,7 @@ This generates:
<html>
<form action="/people" class="new_person" id="new_person" method="post">
<input id="person_name" name="person[name]" size="30" type="text" />
-
+
<input id="person_address_attributes_street" name="person[address_attributes][street]" size="30" type="text" />
</form>
</html>
@@ -183,7 +183,7 @@ The form code for an association collection is pretty similar to that of a singl
<erb>
<%= form_for @person do |f| %>
<%= f.text_field :name %>
-
+
<%= f.fields_for :projects do |pf| %>
<%= f.text_field :name %>
<% end %>
@@ -195,7 +195,7 @@ Which generates:
<html>
<form action="/people" class="new_person" id="new_person" method="post">
<input id="person_name" name="person[name]" size="30" type="text" />
-
+
<input id="person_projects_attributes_0_name" name="person[projects_attributes][0][name]" size="30" type="text" />
<input id="person_projects_attributes_1_name" name="person[projects_attributes][1][name]" size="30" type="text" />
</form>
diff --git a/railties/guides/source/plugins.textile b/railties/guides/source/plugins.textile
index 82f2276153..f89043f216 100644
--- a/railties/guides/source/plugins.textile
+++ b/railties/guides/source/plugins.textile
@@ -323,7 +323,7 @@ Finally, create the +core_ext.rb+ file and add the +to_squawk+ method:
<ruby>
# vendor/plugins/yaffle/lib/yaffle/core_ext.rb
-
+
String.class_eval do
def to_squawk
"squawk! #{self}".strip
diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile
index 1bf9cfec33..bc7b151dfe 100644
--- a/railties/guides/source/rails_application_templates.textile
+++ b/railties/guides/source/rails_application_templates.textile
@@ -79,7 +79,7 @@ plugin 'authentication', :git => 'git://github.com/foor/bar.git'
You can even install plugins as git submodules :
<ruby>
-plugin 'authentication', :git => 'git://github.com/foor/bar.git',
+plugin 'authentication', :git => 'git://github.com/foor/bar.git',
:submodule => true
</ruby>
@@ -103,7 +103,7 @@ class Object
def not_nil?
!nil?
end
-
+
def not_blank?
!blank?
end
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 625941ba31..d92c66cfd2 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -501,7 +501,7 @@ class BlacklistConstraint
end
TwitterClone::Application.routes.draw do
- match "*path" => "blacklist#index",
+ match "*path" => "blacklist#index",
:constraints => BlacklistConstraint.new
end
</ruby>
@@ -765,7 +765,7 @@ formatted_users GET /users.:format {:controller=>"users", :action=>"index"}
You may restrict the listing to the routes that map to a particular controller setting the +CONTROLLER+ environment variable:
<shell>
-$ CONTROLLER=users rake routes
+$ CONTROLLER=users rake routes
</shell>
TIP: You'll find that the output from +rake routes+ is much more readable if you widen your terminal window until the output lines don't wrap.
diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile
index 6372c606b7..4656cf4e40 100644
--- a/railties/guides/source/security.textile
+++ b/railties/guides/source/security.textile
@@ -401,7 +401,7 @@ Note that this vulnerability is not restricted to database columns. Any setter
class Child < ActiveRecord::Base
belongs_to :person
- end
+ end
</ruby>
As a result, the vulnerability is extended beyond simply exposing column assignment, allowing attackers the ability to create entirely new records in referenced tables (children in this case).
diff --git a/railties/guides/w3c_validator.rb b/railties/guides/w3c_validator.rb
index 4da48bf3fb..da5200c0b7 100644
--- a/railties/guides/w3c_validator.rb
+++ b/railties/guides/w3c_validator.rb
@@ -21,7 +21,7 @@
#
# Separate many using commas:
#
-# # validates only
+# # validates only
# ONLY=assoc,migrations rake validate_guides
#
# ---------------------------------------------------------------------------
@@ -32,13 +32,13 @@ include W3CValidators
module RailsGuides
class Validator
-
+
def validate
validator = MarkupValidator.new
STDOUT.sync = true
errors_on_guides = {}
- guides_to_validate.each do |f|
+ guides_to_validate.each do |f|
results = validator.validate_file(f)
if results.validity
@@ -48,10 +48,10 @@ module RailsGuides
errors_on_guides[f] = results.errors
end
end
-
+
show_results(errors_on_guides)
end
-
+
private
def guides_to_validate
guides = Dir["./guides/output/*.html"]
@@ -65,13 +65,13 @@ module RailsGuides
prefixes.any? {|p| guide.start_with?("./guides/output/#{p}")}
end
end
-
+
def show_results(error_list)
if error_list.size == 0
puts "\n\nAll checked guides validate OK!"
else
error_summary = error_detail = ""
-
+
error_list.each_pair do |name, errors|
error_summary += "\n #{name}"
error_detail += "\n\n #{name} has #{errors.size} validation error(s):\n"
@@ -79,12 +79,12 @@ module RailsGuides
error_detail += "\n "+error.to_s.gsub("\n", "")
end
end
-
+
puts "\n\nThere are #{error_list.size} guides with validation errors:\n" + error_summary
puts "\nHere are the detailed errors for each guide:" + error_detail
end
end
-
+
end
end
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb
index 740d8a1767..57e29a0045 100644
--- a/railties/lib/rails/code_statistics.rb
+++ b/railties/lib/rails/code_statistics.rb
@@ -12,7 +12,7 @@ class CodeStatistics #:nodoc:
print_header
@pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) }
print_splitter
-
+
if @total
print_line("Total", @total)
print_splitter
@@ -29,7 +29,7 @@ class CodeStatistics #:nodoc:
def calculate_directory_statistics(directory, pattern = /.*\.rb$/)
stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
- Dir.foreach(directory) do |file_name|
+ Dir.foreach(directory) do |file_name|
if File.stat(directory + "/" + file_name).directory? and (/^\./ !~ file_name)
newstats = calculate_directory_statistics(directory + "/" + file_name, pattern)
stats.each { |k, v| stats[k] += newstats[k] }
@@ -85,10 +85,10 @@ class CodeStatistics #:nodoc:
start = if TEST_TYPES.include? name
"| #{name.ljust(20)} "
else
- "| #{name.ljust(20)} "
+ "| #{name.ljust(20)} "
end
- puts start +
+ puts start +
"| #{statistics["lines"].to_s.rjust(5)} " +
"| #{statistics["codelines"].to_s.rjust(5)} " +
"| #{statistics["classes"].to_s.rjust(7)} " +
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index fdfceb14ce..f97f3db588 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -81,7 +81,7 @@ module Rails
# guessed based on class invokes hook_for, as noticed in the example above.
# This can be customized with two options: :base and :as.
#
- # Let's suppose you are creating a generator that needs to invoke the
+ # Let's suppose you are creating a generator that needs to invoke the
# controller generator from test unit. Your first attempt is:
#
# class AwesomeGenerator < Rails::Generators::Base
diff --git a/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js b/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
index 066ee5909c..c81e6c7d5f 100644
--- a/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
+++ b/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
@@ -150,7 +150,7 @@ var Effect = {
toggle: function(element, effect, options) {
element = $(element);
effect = (effect || 'appear').toLowerCase();
-
+
return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
}, options || {}));
diff --git a/railties/lib/rails/generators/rails/generator/USAGE b/railties/lib/rails/generators/rails/generator/USAGE
index d8c3f7f634..d68539e4a6 100644
--- a/railties/lib/rails/generators/rails/generator/USAGE
+++ b/railties/lib/rails/generators/rails/generator/USAGE
@@ -1,6 +1,6 @@
Description:
Stubs out a new generator at lib/generators. Pass the generator name, either
- CamelCased or under_scored, as an argument.
+ CamelCased or under_scored, as an argument.
Example:
`rails generate generator Awesome`
diff --git a/railties/lib/rails/generators/rails/migration/USAGE b/railties/lib/rails/generators/rails/migration/USAGE
index d21c81b760..af74963b01 100644
--- a/railties/lib/rails/generators/rails/migration/USAGE
+++ b/railties/lib/rails/generators/rails/migration/USAGE
@@ -18,12 +18,12 @@ Example:
This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with
this in the Up migration:
- add_column :posts, :title, :string
- add_column :posts, :body, :text
+ add_column :posts, :title, :string
+ add_column :posts, :body, :text
add_column :posts, :published, :boolean
And this in the Down migration:
- remove_column :posts, :published
- remove_column :posts, :body
+ remove_column :posts, :published
+ remove_column :posts, :body
remove_column :posts, :title
diff --git a/railties/lib/rails/generators/rails/plugin/USAGE b/railties/lib/rails/generators/rails/plugin/USAGE
index 00a429c585..1bcfcf190d 100644
--- a/railties/lib/rails/generators/rails/plugin/USAGE
+++ b/railties/lib/rails/generators/rails/plugin/USAGE
@@ -1,6 +1,6 @@
Description:
Stubs out a new plugin at vendor/plugins. Pass the plugin name, either
- CamelCased or under_scored, as an argument.
+ CamelCased or under_scored, as an argument.
Example:
`rails generate plugin BrowserFilters`
diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb
index fc070026d6..8a943013d3 100644
--- a/railties/lib/rails/generators/rails/resource/resource_generator.rb
+++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -16,9 +16,9 @@ module Rails
def add_resource_route
return if options[:actions].present?
- route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
+ route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
route_config << "resources :#{file_name.pluralize}"
- route_config << " end" * class_path.size
+ route_config << " end" * class_path.size
route route_config
end
end
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index be229cc9a2..8d5132a5ca 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -16,7 +16,7 @@ module Rails
# Besides this conceptual difference, the only difference between Rails::Engine and
# Rails::Plugin is that plugins automatically load the file "init.rb" at the plugin
# root during the boot process.
- #
+ #
class Plugin < Engine
def self.inherited(base)
raise "You cannot inherit from Rails::Plugin"
diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb
index 8a6e2716dc..2684552701 100644
--- a/railties/lib/rails/railtie.rb
+++ b/railties/lib/rails/railtie.rb
@@ -48,7 +48,7 @@ module Rails
# # lib/my_gem/railtie.rb
# require 'my_gem'
# require 'rails'
- #
+ #
# module MyGem
# class Railtie < Rails::Railtie
# end
@@ -121,7 +121,7 @@ module Rails
# described here can be used in all three.
#
# Be sure to look at the documentation of those specific classes for more information.
- #
+ #
class Railtie
autoload :Configurable, "rails/railtie/configurable"
autoload :Configuration, "rails/railtie/configuration"
diff --git a/railties/lib/rails/script_rails_loader.rb b/railties/lib/rails/script_rails_loader.rb
index 91672e5d81..7054089614 100644
--- a/railties/lib/rails/script_rails_loader.rb
+++ b/railties/lib/rails/script_rails_loader.rb
@@ -17,11 +17,11 @@ module Rails
rescue SystemCallError
# could not chdir, no problem just return
end
-
+
def self.in_rails_application?
File.exists?(SCRIPT_RAILS)
end
-
+
def self.in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd))
File.exists?(File.join(path, SCRIPT_RAILS)) || !path.root? && in_rails_application_subdirectory?(path.parent)
end
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake
index c1b1a41d48..7aefbb49b0 100644
--- a/railties/lib/rails/tasks/documentation.rake
+++ b/railties/lib/rails/tasks/documentation.rake
@@ -4,15 +4,15 @@ require 'rake/rdoctask'
class RDocTaskWithoutDescriptions < Rake::RDocTask
def define
task rdoc_task_name
-
+
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
-
+
task clobber_task_name do
rm_r rdoc_dir rescue nil
end
-
+
task :clobber => [clobber_task_name]
-
+
directory @rdoc_dir
task rdoc_task_name => [rdoc_target]
file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb
index 340ce67511..ecf7904c39 100644
--- a/railties/test/application/loading_test.rb
+++ b/railties/test/application/loading_test.rb
@@ -18,10 +18,10 @@ class LoadingTest < Test::Unit::TestCase
validates_acceptance_of :title, :accept => "omg"
end
MODEL
-
+
require "#{rails_root}/config/environment"
setup_ar!
-
+
p = Post.create(:title => 'omg')
assert_equal 1, Post.count
assert_equal 'omg', p.title
@@ -73,7 +73,7 @@ class LoadingTest < Test::Unit::TestCase
end
protected
-
+
def setup_ar!
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Migration.verbose = false
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index d6e100ffe3..454c9511d8 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -14,7 +14,7 @@ module ApplicationTests
app_file "lib/tasks/app.rake", <<-RUBY
$task_loaded = Rake::Task.task_defined?("db:create:all")
RUBY
-
+
require "#{app_path}/config/environment"
::Rails.application.load_tasks
assert $task_loaded
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 0472ca73a8..f5473333ed 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -88,7 +88,7 @@ class ActionsTest < Rails::Generators::TestCase
assert_deprecated do
action :gem, 'thoughtbot-factory_girl', :require_as => 'factory_girl', :source => 'http://gems.github.com'
- end
+ end
assert_file 'Gemfile', /gem "mislav\-will\-paginate", :require => "will\-paginate"/
assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
@@ -103,7 +103,7 @@ class ActionsTest < Rails::Generators::TestCase
end
assert_deprecated do
- action :gem, 'rspec-rails', :only => %w(development test)
+ action :gem, 'rspec-rails', :only => %w(development test)
end
assert_file 'Gemfile', /gem "rspec", :group => \["development", "test"\]/
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 08cfb585f9..849c8001f4 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -79,7 +79,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
reserved_words = %w[application destroy plugin runner test]
reserved_words.each do |reserved|
content = capture(:stderr){ run_generator [File.join(destination_root, reserved)] }
- assert_equal "Invalid application name #{reserved}. Please give a name which does not match one of the reserved rails words.\n", content
+ assert_equal "Invalid application name #{reserved}. Please give a name which does not match one of the reserved rails words.\n", content
end
end
diff --git a/railties/test/railties/railtie_test.rb b/railties/test/railties/railtie_test.rb
index db0fd87491..6715003d3d 100644
--- a/railties/test/railties/railtie_test.rb
+++ b/railties/test/railties/railtie_test.rb
@@ -132,7 +132,7 @@ module RailtiesTest
require "#{app_path}/config/environment"
assert $ran_block
end
-
+
test "we can change our environment if we want to" do
begin
original_env = Rails.env
diff --git a/railties/test/script_rails_loader_test.rb b/railties/test/script_rails_loader_test.rb
index 2a87e5cb58..3ccc147749 100644
--- a/railties/test/script_rails_loader_test.rb
+++ b/railties/test/script_rails_loader_test.rb
@@ -2,21 +2,21 @@ require 'abstract_unit'
require 'rails/script_rails_loader'
class ScriptRailsLoaderTest < ActiveSupport::TestCase
-
+
test "is in a rails application if script/rails exists" do
File.stubs(:exists?).returns(true)
assert Rails::ScriptRailsLoader.in_rails_application?
end
-
+
test "is in a rails application if parent directory has script/rails" do
File.stubs(:exists?).with("/foo/bar/script/rails").returns(false)
File.stubs(:exists?).with("/foo/script/rails").returns(true)
assert Rails::ScriptRailsLoader.in_rails_application_subdirectory?(Pathname.new("/foo/bar"))
end
-
+
test "is not in a rails application if at the root directory and doesn't have script/rails" do
Pathname.any_instance.stubs(:root?).returns true
assert !Rails::ScriptRailsLoader.in_rails_application?
end
-
+
end \ No newline at end of file