Skip to content

Commit 3e24e9e

Browse files
committed
Merge branch 'master' of git://github.com/lifo/docrails
2 parents a000fc5 + 4c323bc commit 3e24e9e

29 files changed

+119
-99
lines changed

actionmailer/README.rdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This can be as simple as:
3232
end
3333

3434
The body of the email is created by using an Action View template (regular
35-
ERb) that has the instance variables that are declared in the mailer action.
35+
ERB) that has the instance variables that are declared in the mailer action.
3636

3737
So the corresponding body template for the method above could look like this:
3838

actionpack/README.rdoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ It consists of several modules:
1919

2020
* Action View, which handles view template lookup and rendering, and provides
2121
view helpers that assist when building HTML forms, Atom feeds and more.
22-
Template formats that Action View handles are ERb (embedded Ruby, typically
22+
Template formats that Action View handles are ERB (embedded Ruby, typically
2323
used to inline short Ruby snippets inside HTML), XML Builder and RJS
2424
(dynamically generated JavaScript from Ruby code).
2525

@@ -57,7 +57,7 @@ A short rundown of some of the major features:
5757
{Learn more}[link:classes/ActionController/Base.html]
5858

5959

60-
* ERb templates (static content mixed with dynamic output from ruby)
60+
* ERB templates (static content mixed with dynamic output from ruby)
6161

6262
<% for post in @posts %>
6363
Title: <%= post.title %>

actionpack/lib/action_controller/base.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ module ActionController
105105
# == Renders
106106
#
107107
# Action Controller sends content to the user by using one of five rendering methods. The most versatile and common is the rendering
108-
# of a template. Included in the Action Pack is the Action View, which enables rendering of ERb templates. It's automatically configured.
108+
# of a template. Included in the Action Pack is the Action View, which enables rendering of ERB templates. It's automatically configured.
109109
# The controller passes objects to the view by assigning instance variables:
110110
#
111111
# def show
@@ -128,7 +128,7 @@ module ActionController
128128
# end
129129
# end
130130
#
131-
# Read more about writing ERb and Builder templates in ActionView::Base.
131+
# Read more about writing ERB and Builder templates in ActionView::Base.
132132
#
133133
# == Redirects
134134
#

actionpack/lib/action_controller/metal.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,23 @@ def to_a #:nodoc:
201201
class_attribute :middleware_stack
202202
self.middleware_stack = ActionController::MiddlewareStack.new
203203

204-
def self.inherited(base)
204+
def self.inherited(base) #nodoc:
205205
base.middleware_stack = self.middleware_stack.dup
206206
super
207207
end
208208

209+
# Adds given middleware class and its args to bottom of middleware_stack
209210
def self.use(*args, &block)
210211
middleware_stack.use(*args, &block)
211212
end
212213

214+
# Alias for middleware_stack
213215
def self.middleware
214216
middleware_stack
215217
end
216218

219+
# Makes the controller a rack endpoint that points to the action in
220+
# the given env's action_dispatch.request.path_parameters key.
217221
def self.call(env)
218222
action(env['action_dispatch.request.path_parameters'][:action]).call(env)
219223
end

actionpack/lib/action_controller/metal/http_authentication.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module HttpAuthentication
6767
# class PostsController < ApplicationController
6868
# REALM = "SuperSecret"
6969
# USERS = {"dhh" => "secret", #plain text password
70-
# "dap" => Digest:MD5::hexdigest(["dap",REALM,"secret"].join(":")) #ha1 digest password
70+
# "dap" => Digest::MD5.hexdigest(["dap",REALM,"secret"].join(":")) #ha1 digest password
7171
#
7272
# before_filter :authenticate, :except => [:index]
7373
#

actionpack/lib/action_controller/metal/mime_responds.rb

+3
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ def respond_to(*mimes, &block)
222222
# is quite simple (it just needs to respond to call), you can even give
223223
# a proc to it.
224224
#
225+
# In order to use respond_with, first you need to declare the formats your
226+
# controller responds to in the class level with a call to <tt>respond_to</tt>.
227+
#
225228
def respond_with(*resources, &block)
226229
raise "In order to use respond_with, first you need to declare the formats your " <<
227230
"controller responds to in the class level" if self.class.mimes_for_respond_to.empty?

actionpack/lib/action_dispatch/testing/integration.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,31 @@ module RequestHelpers
2626
# object's <tt>@response</tt> instance variable will point to the same
2727
# response object.
2828
#
29-
# You can also perform POST, PUT, DELETE, and HEAD requests with +post+,
30-
# +put+, +delete+, and +head+.
29+
# You can also perform POST, PUT, DELETE, and HEAD requests with +#post+,
30+
# +#put+, +#delete+, and +#head+.
3131
def get(path, parameters = nil, headers = nil)
3232
process :get, path, parameters, headers
3333
end
3434

35-
# Performs a POST request with the given parameters. See get() for more
35+
# Performs a POST request with the given parameters. See +#get+ for more
3636
# details.
3737
def post(path, parameters = nil, headers = nil)
3838
process :post, path, parameters, headers
3939
end
4040

41-
# Performs a PUT request with the given parameters. See get() for more
41+
# Performs a PUT request with the given parameters. See +#get+ for more
4242
# details.
4343
def put(path, parameters = nil, headers = nil)
4444
process :put, path, parameters, headers
4545
end
4646

47-
# Performs a DELETE request with the given parameters. See get() for
47+
# Performs a DELETE request with the given parameters. See +#get+ for
4848
# more details.
4949
def delete(path, parameters = nil, headers = nil)
5050
process :delete, path, parameters, headers
5151
end
5252

53-
# Performs a HEAD request with the given parameters. See get() for more
53+
# Performs a HEAD request with the given parameters. See +#get+ for more
5454
# details.
5555
def head(path, parameters = nil, headers = nil)
5656
process :head, path, parameters, headers
@@ -59,7 +59,7 @@ def head(path, parameters = nil, headers = nil)
5959
# Performs an XMLHttpRequest request with the given parameters, mirroring
6060
# a request from the Prototype library.
6161
#
62-
# The request_method is :get, :post, :put, :delete or :head; the
62+
# The request_method is +:get+, +:post+, +:put+, +:delete+ or +:head+; the
6363
# parameters are +nil+, a hash, or a url-encoded or multipart string;
6464
# the headers are a hash. Keys are automatically upcased and prefixed
6565
# with 'HTTP_' if not already.
@@ -384,7 +384,7 @@ def integration_session
384384
end
385385
end
386386

387-
# An test that spans multiple controllers and actions,
387+
# An integration test spans multiple controllers and actions,
388388
# tying them all together to ensure they work together as expected. It tests
389389
# more completely than either unit or functional tests do, exercising the
390390
# entire stack, from the dispatcher to the database.

actionpack/lib/action_view/base.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
module ActionView #:nodoc:
99
# = Action View Base
1010
#
11-
# Action View templates can be written in three ways. If the template file has a <tt>.erb</tt> (or <tt>.rhtml</tt>) extension then it uses a mixture of ERb
11+
# Action View templates can be written in three ways. If the template file has a <tt>.erb</tt> (or <tt>.rhtml</tt>) extension then it uses a mixture of ERB
1212
# (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> (or <tt>.rxml</tt>) extension then Jim Weirich's Builder::XmlMarkup library is used.
1313
# If the template file has a <tt>.rjs</tt> extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.
1414
#
15-
# == ERb
15+
# == ERB
1616
#
17-
# You trigger ERb by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
17+
# You trigger ERB by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
1818
# following loop for names:
1919
#
2020
# <b>Names of all the people</b>
@@ -23,7 +23,7 @@ module ActionView #:nodoc:
2323
# <% end %>
2424
#
2525
# The loop is setup in regular embedding tags <% %> and the name is written using the output embedding tag <%= %>. Note that this
26-
# is not just a usage suggestion. Regular output functions like print or puts won't work with ERb templates. So this would be wrong:
26+
# is not just a usage suggestion. Regular output functions like print or puts won't work with ERB templates. So this would be wrong:
2727
#
2828
# <%# WRONG %>
2929
# Hi, Mr. <% puts "Frodo" %>
@@ -81,7 +81,7 @@ module ActionView #:nodoc:
8181
#
8282
# == Builder
8383
#
84-
# Builder templates are a more programmatic alternative to ERb. They are especially useful for generating XML content. An XmlMarkup object
84+
# Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object
8585
# named +xml+ is automatically made available to templates with a <tt>.builder</tt> extension.
8686
#
8787
# Here are some basic examples:

actionpack/lib/action_view/helpers/atom_feed_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ActionView
44
# = Action View Atom Feed Helpers
55
module Helpers #:nodoc:
66
module AtomFeedHelper
7-
# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other
7+
# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERB or any other
88
# template languages).
99
#
1010
# Full usage example:

actionpack/lib/action_view/helpers/capture_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module CaptureHelper
1414
# variable. You can then use this variable anywhere in your templates or layout.
1515
#
1616
# ==== Examples
17-
# The capture method can be used in ERb templates...
17+
# The capture method can be used in ERB templates...
1818
#
1919
# <% @greeting = capture do %>
2020
# Welcome to my shiny new web page! The date and time is

actionpack/lib/action_view/helpers/prototype_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def update_page(&block)
584584

585585
# Works like update_page but wraps the generated JavaScript in a
586586
# <tt>\<script></tt> tag. Use this to include generated JavaScript in an
587-
# ERb template. See JavaScriptGenerator for more information.
587+
# ERB template. See JavaScriptGenerator for more information.
588588
#
589589
# +html_options+ may be a hash of <tt>\<script></tt> attributes to be
590590
# passed to ActionView::Helpers::JavaScriptHelper#javascript_tag.

actionpack/lib/action_view/helpers/url_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def url_for(options = {})
183183
# link_to "Profiles", :controller => "profiles"
184184
# # => <a href="/profiles">Profiles</a>
185185
#
186-
# You can use a block as well if your link target is hard to fit into the name parameter. ERb example:
186+
# You can use a block as well if your link target is hard to fit into the name parameter. ERB example:
187187
#
188188
# <%= link_to(@profile) do %>
189189
# <strong><%= @profile.name %></strong> -- <span>Check it out!</span>

actionpack/lib/action_view/template/handlers/erb.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def add_postamble(src)
5555

5656
class ERB
5757
# Specify trim mode for the ERB compiler. Defaults to '-'.
58-
# See ERb documentation for suitable values.
58+
# See ERB documentation for suitable values.
5959
class_attribute :erb_trim_mode
6060
self.erb_trim_mode = '-'
6161

activemodel/lib/active_model/errors.rb

+10-11
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,18 @@ def full_messages
278278
# When using inheritance in your models, it will check all the inherited
279279
# models too, but only if the model itself hasn't been found. Say you have
280280
# <tt>class Admin < User; end</tt> and you wanted the translation for
281-
# the <tt>:blank</tt> error +message+ for the <tt>title</tt> +attribute+,
281+
# the <tt>:blank</tt> error message for the <tt>title</tt> attribute,
282282
# it looks for these translations:
283283
#
284-
# <ol>
285-
# <li><tt>activemodel.errors.models.admin.attributes.title.blank</tt></li>
286-
# <li><tt>activemodel.errors.models.admin.blank</tt></li>
287-
# <li><tt>activemodel.errors.models.user.attributes.title.blank</tt></li>
288-
# <li><tt>activemodel.errors.models.user.blank</tt></li>
289-
# <li>any default you provided through the +options+ hash (in the activemodel.errors scope)</li>
290-
# <li><tt>activemodel.errors.messages.blank</tt></li>
291-
# <li><tt>errors.attributes.title.blank</tt></li>
292-
# <li><tt>errors.messages.blank</tt></li>
293-
# </ol>
284+
# * <tt>activemodel.errors.models.admin.attributes.title.blank</tt>
285+
# * <tt>activemodel.errors.models.admin.blank</tt>
286+
# * <tt>activemodel.errors.models.user.attributes.title.blank</tt>
287+
# * <tt>activemodel.errors.models.user.blank</tt>
288+
# * any default you provided through the +options+ hash (in the <tt>activemodel.errors</tt> scope)
289+
# * <tt>activemodel.errors.messages.blank</tt>
290+
# * <tt>errors.attributes.title.blank</tt>
291+
# * <tt>errors.messages.blank</tt>
292+
#
294293
def generate_message(attribute, type = :invalid, options = {})
295294
type = options.delete(:message) if options[:message].is_a?(Symbol)
296295

activerecord/lib/active_record/callbacks.rb

+18
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ module ActiveRecord
214214
# needs to be aware of it because an ordinary +save+ will raise such exception
215215
# instead of quietly returning +false+.
216216
#
217+
# == Debugging callbacks
218+
#
219+
# The callback chain is accessible via the <tt>_*_callbacks</tt> method on an object. ActiveModel Callbacks support
220+
# <tt>:before</tt>, <tt>:after</tt> and <tt>:around</tt> as values for the <tt>kind</tt> property. The <tt>kind</tt> property
221+
# defines what part of the chain the callback runs in.
222+
#
223+
# To find all callbacks in the before_save callback chain:
224+
#
225+
# Topic._save_callbacks.select { |cb| cb.kind.eql?(:before) }
226+
#
227+
# Returns an array of callback objects that form the before_save chain.
228+
#
229+
# To further check if the before_save chain contains a proc defined as <tt>rest_when_dead</tt> use the <tt>filter</tt> property of the callback object:
230+
#
231+
# Topic._save_callbacks.select { |cb| cb.kind.eql?(:before) }.collect(&:filter).include?(:rest_when_dead)
232+
#
233+
# Returns true or false depending on whether the proc is contained in the before_save callback chain on a Topic model.
234+
#
217235
module Callbacks
218236
extend ActiveSupport::Concern
219237

activerecord/lib/active_record/fixtures.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ class FixturesFileNotFound < StandardError; end
173173
# traversed in the database to create the fixture hash and/or instance variables. This is expensive for
174174
# large sets of fixtured data.
175175
#
176-
# = Dynamic fixtures with ERb
176+
# = Dynamic fixtures with ERB
177177
#
178178
# Some times you don't care about the content of the fixtures as much as you care about the volume. In these cases, you can
179-
# mix ERb in with your YAML or CSV fixtures to create a bunch of fixtures for load testing, like:
179+
# mix ERB in with your YAML or CSV fixtures to create a bunch of fixtures for load testing, like:
180180
#
181181
# <% for i in 1..1000 %>
182182
# fix_<%= i %>:
@@ -186,7 +186,7 @@ class FixturesFileNotFound < StandardError; end
186186
#
187187
# This will create 1000 very simple YAML fixtures.
188188
#
189-
# Using ERb, you can also inject dynamic values into your fixtures with inserts like <tt><%= Date.today.strftime("%Y-%m-%d") %></tt>.
189+
# Using ERB, you can also inject dynamic values into your fixtures with inserts like <tt><%= Date.today.strftime("%Y-%m-%d") %></tt>.
190190
# This is however a feature to be used with some caution. The point of fixtures are that they're
191191
# stable units of predictable sample data. If you feel that you need to inject dynamic values, then
192192
# perhaps you should reexamine whether your application is properly testable. Hence, dynamic values

activerecord/lib/active_record/named_scope.rb

+23
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,29 @@ def scoped(options = nil)
9999
#
100100
# Article.published.new.published # => true
101101
# Article.published.create.published # => true
102+
#
103+
# Class methods on your model are automatically available
104+
# on scopes. Assuming the following setup:
105+
#
106+
# class Article < ActiveRecord::Base
107+
# scope :published, where(:published => true)
108+
# scope :featured, where(:featured => true)
109+
#
110+
# def self.latest_article
111+
# order('published_at desc').first
112+
# end
113+
#
114+
# def self.titles
115+
# map(&:title)
116+
# end
117+
#
118+
# end
119+
#
120+
# We are able to call the methods like this:
121+
#
122+
# Article.published.featured.latest_article
123+
# Article.featured.titles
124+
102125
def scope(name, scope_options = {})
103126
name = name.to_sym
104127
valid_scope_name?(name)

activesupport/lib/active_support/core_ext/string/output_safety.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Util
99
# A utility method for escaping HTML tag characters.
1010
# This method is also aliased as <tt>h</tt>.
1111
#
12-
# In your ERb templates, use this method to escape any unsafe content. For example:
12+
# In your ERB templates, use this method to escape any unsafe content. For example:
1313
# <%=h @person.name %>
1414
#
1515
# ==== Example:

railties/guides/source/action_controller_overview.textile

+3-14
Original file line numberDiff line numberDiff line change
@@ -615,26 +615,15 @@ Rails comes with two built-in HTTP authentication mechanisms:
615615

616616
h4. HTTP Basic Authentication
617617

618-
HTTP basic authentication is an authentication scheme that is supported by the majority of browsers and other HTTP clients. As an example, consider an administration section which will only be available by entering a username and a password into the browser's HTTP basic dialog window. Using the built-in authentication is quite easy and only requires you to use one method, +authenticate_or_request_with_http_basic+.
618+
HTTP basic authentication is an authentication scheme that is supported by the majority of browsers and other HTTP clients. As an example, consider an administration section which will only be available by entering a username and a password into the browser's HTTP basic dialog window. Using the built-in authentication is quite easy and only requires you to use one method, +http_basic_authenticate_with+.
619619

620620
<ruby>
621621
class AdminController < ApplicationController
622-
USERNAME, PASSWORD = "humbaba", "5baa61e4"
623-
624-
before_filter :authenticate
625-
626-
private
627-
628-
def authenticate
629-
authenticate_or_request_with_http_basic do |username, password|
630-
username == USERNAME &&
631-
Digest::SHA1.hexdigest(password) == PASSWORD
632-
end
633-
end
622+
http_basic_authenticate_with :name => "humbaba", :password => "5baa61e4"
634623
end
635624
</ruby>
636625

637-
With this in place, you can create namespaced controllers that inherit from +AdminController+. The before filter will thus be run for all actions in those controllers, protecting them with HTTP basic authentication.
626+
With this in place, you can create namespaced controllers that inherit from +AdminController+. The filter will thus be run for all actions in those controllers, protecting them with HTTP basic authentication.
638627

639628
h4. HTTP Digest Authentication
640629

railties/guides/source/action_view_overview.textile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ end
12951295

12961296
h5. update_page_tag
12971297

1298-
Works like update_page but wraps the generated JavaScript in a +script+ tag. Use this to include generated JavaScript in an ERb template.
1298+
Works like update_page but wraps the generated JavaScript in a +script+ tag. Use this to include generated JavaScript in an ERB template.
12991299

13001300
h4. PrototypeHelper::JavaScriptGenerator::GeneratorMethods
13011301

railties/guides/source/api_documentation_guidelines.textile

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Documentation has to be concise but comprehensive. Explore and document edge cas
2929

3030
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. All Rails documentation should 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 phenomenal.
3131

32-
Spell names correctly: Arel, Test::Unit, RSpec, HTML, MySQL, JavaScript, ERb. When in doubt, please have a look at some authoritative source like their official documentation.
32+
Spell names correctly: Arel, Test::Unit, RSpec, HTML, MySQL, JavaScript, ERB. When in doubt, please have a look at some authoritative source like their official documentation.
3333

3434
Use the article "an" for "SQL", as in "an SQL statement". Also "an SQLite database".
3535

railties/guides/source/command_line.textile

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ end
484484
We take whatever args are supplied, save them to an instance variable, and literally copying from the Rails source, implement a +manifest+ method, which calls +record+ with a block, and we:
485485

486486
* Check there's a *public* directory. You bet there is.
487-
* Run the ERb template called "tutorial.erb".
487+
* Run the ERB template called "tutorial.erb".
488488
* Save it into "Rails.root/public/tutorial.txt".
489489
* Pass in the arguments we saved through the +:assigns+ parameter.
490490

0 commit comments

Comments
 (0)