Merge branch 'master' of git://github.com/lifo/docrails

Conflicts:
	railties/guides/source/ajax_on_rails.textile
	railties/guides/source/generators.textile
This commit is contained in:
Xavier Noria 2011-04-19 21:54:10 +02:00
commit e162e912c9
34 changed files with 547 additions and 170 deletions

@ -297,6 +297,10 @@ module ActionMailer #:nodoc:
# information and a cryptographic Message Digest 5 algorithm to hash important information)
# * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server
# and starts to use it.
# * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
# really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
# of an OpenSSL verify constant ('none', 'peer', 'client_once','fail_if_no_peer_cert') or directly the
# constant (OpenSSL::SSL::VERIFY_NONE, OpenSSL::SSL::VERIFY_PEER,...).
#
# * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
# * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
@ -682,6 +686,9 @@ def set_content_type(m, user_content_type, class_default)
end
end
# Translates the +subject+ using Rails I18n class under <tt>[:actionmailer, mailer_scope, action_name]</tt> scope.
# If it does not find a translation for the +subject+ under the specified scope it will default to a
# humanized version of the <tt>action_name</tt>.
def default_i18n_subject #:nodoc:
mailer_scope = self.class.mailer_name.gsub('/', '.')
I18n.t(:subject, :scope => [mailer_scope, action_name], :default => action_name.humanize)

@ -51,7 +51,7 @@ module DateHelper
# distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute
# distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 seconds
# distance_of_time_in_words(from_time, 3.years.from_now) # => about 3 years
# distance_of_time_in_words(from_time, from_time + 60.hours) # => about 3 days
# distance_of_time_in_words(from_time, from_time + 60.hours) # => 3 days
# distance_of_time_in_words(from_time, from_time + 45.seconds, true) # => less than a minute
# distance_of_time_in_words(from_time, from_time - 45.seconds, true) # => less than a minute
# distance_of_time_in_words(from_time, 76.seconds.from_now) # => 1 minute
@ -112,10 +112,12 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, o
#
# ==== Examples
# time_ago_in_words(3.minutes.from_now) # => 3 minutes
# time_ago_in_words(Time.now - 15.hours) # => 15 hours
# time_ago_in_words(Time.now - 15.hours) # => about 15 hours
# time_ago_in_words(Time.now) # => less than a minute
#
# from_time = Time.now - 3.days - 14.minutes - 25.seconds # => 3 days
# from_time = Time.now - 3.days - 14.minutes - 25.seconds
# time_ago_in_words(from_time) # => 3 days
#
def time_ago_in_words(from_time, include_seconds = false)
distance_of_time_in_words(from_time, Time.now, include_seconds)
end

@ -100,7 +100,7 @@ def number_to_phone(number, options = {})
# number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506
# number_to_currency(1234567890.506, :locale => :fr) # => 1 234 567 890,506 €
#
# number_to_currency(1234567890.50, :negative_format => "(%u%n)")
# number_to_currency(-1234567890.50, :negative_format => "(%u%n)")
# # => ($1,234,567,890.51)
# number_to_currency(1234567890.50, :unit => "&pound;", :separator => ",", :delimiter => "")
# # => &pound;1234567890,50
@ -238,7 +238,7 @@ def number_with_delimiter(number, options = {})
# number_with_precision(111.2345, :precision => 1, :significant => true) # => 100
# number_with_precision(13, :precision => 5, :significant => true) # => 13.000
# number_with_precision(111.234, :locale => :fr) # => 111,234
# number_with_precision(13, :precision => 5, :significant => true, strip_insignificant_zeros => true)
# number_with_precision(13, :precision => 5, :significant => true, :strip_insignificant_zeros => true)
# # => 13
# number_with_precision(389.32314, :precision => 4, :significant => true) # => 389.3
# number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')

@ -94,7 +94,7 @@ def strip_tags(html)
# # => Please e-mail me at me@email.com.
#
# strip_links('Blog: <a href="http://www.myblog.com/" class="nav" target=\"_blank\">Visit</a>.')
# # => Blog: Visit
# # => Blog: Visit.
def strip_links(html)
self.class.link_sanitizer.sanitize(html)
end

@ -19,7 +19,7 @@ module Helpers #:nodoc:
# simple_format('<a href="http://example.com/">Example</a>')
# # => "<p><a href=\"http://example.com/\">Example</a></p>"
#
# simple_format('<a href="javascript:alert('no!')">Example</a>')
# simple_format('<a href="javascript:alert(\'no!\')">Example</a>')
# # => "<p><a>Example</a></p>"
#
# If you want to escape all content, you should invoke the +h+ method before
@ -295,11 +295,11 @@ def simple_format(text, html_options={}, options={})
# +link+ as its optional second parameter and the +html_options+ hash
# as its optional third parameter:
# post_body = "Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com."
# auto_link(post_body, :urls) # => Once upon\na time
# auto_link(post_body, :urls)
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\">http://www.myblog.com</a>.
# Please e-mail me at me@email.com."
#
# auto_link(post_body, :all, :target => "_blank") # => Once upon\na time
# auto_link(post_body, :all, :target => "_blank")
# # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.myblog.com</a>.
# Please e-mail me at <a href=\"mailto:me@email.com\">me@email.com</a>."
def auto_link(text, *args, &block)#link = :all, html = {}, &block)

@ -1,10 +1,13 @@
class Array
# Backport of Array#sample based on Marc-Andre Lafortune's https://github.com/marcandre/backports/
# Returns a random element or +n+ random elements from the array.
# If the array is empty and +n+ is nil, returns <tt>nil</tt>. if +n+ is passed, returns <tt>[]</tt>.
# If the array is empty and +n+ is nil, returns <tt>nil</tt>.
# If +n+ is passed and its value is less than 0, it raises an +ArgumentError+ exception.
# If the value of +n+ is equal or greater than 0 it returns <tt>[]</tt>.
#
# [1,2,3,4,5,6].sample # => 4
# [1,2,3,4,5,6].sample(3) # => [2, 4, 5]
# [1,2,3,4,5,6].sample(-3) # => ArgumentError: negative sample number
# [].sample # => nil
# [].sample(3) # => []
def sample(n=nil)

@ -18,8 +18,8 @@ def present?
!blank?
end
# Returns object if it's #present? otherwise returns nil.
# object.presence is equivalent to object.present? ? object : nil.
# Returns object if it's <tt>present?</tt> otherwise returns +nil+.
# <tt>object.presence</tt> is equivalent to <tt>object.present? ? object : nil</tt>.
#
# This is handy for any representation of objects where blank is the same
# as not present at all. For example, this simplifies a common check for
@ -37,39 +37,72 @@ def presence
end
end
class NilClass #:nodoc:
class NilClass
# +nil+ is blank:
#
# nil.blank? # => true
#
def blank?
true
end
end
class FalseClass #:nodoc:
class FalseClass
# +false+ is blank:
#
# false.blank? # => true
#
def blank?
true
end
end
class TrueClass #:nodoc:
class TrueClass
# +true+ is not blank:
#
# true.blank? # => false
#
def blank?
false
end
end
class Array #:nodoc:
class Array
# An array is blank if it's empty:
#
# [].blank? # => true
# [1,2,3].blank? # => false
#
alias_method :blank?, :empty?
end
class Hash #:nodoc:
class Hash
# A hash is blank if it's empty:
#
# {}.blank? # => true
# {:key => 'value'}.blank? # => false
#
alias_method :blank?, :empty?
end
class String #:nodoc:
class String
# A string is blank if it's empty or contains whitespaces only:
#
# "".blank? # => true
# " ".blank? # => true
# " something here ".blank? # => false
#
def blank?
self !~ /\S/
end
end
class Numeric #:nodoc:
# No number is blank:
#
# 1.blank? # => false
# 0.blank? # => false
#
def blank?
false
end

@ -15,50 +15,89 @@
# That's why we hardcode the following cases and check duplicable? instead of
# using that rescue idiom.
class Object
# Can you safely .dup this object?
# False for nil, false, true, symbols, numbers, class and module objects; true otherwise.
# Can you safely dup this object?
#
# False for +nil+, +false+, +true+, symbols, numbers, class and module objects;
# true otherwise.
def duplicable?
true
end
end
class NilClass #:nodoc:
class NilClass
# +nil+ is not duplicable:
#
# nil.duplicable? # => false
# nil.dup # => TypeError: can't dup NilClass
#
def duplicable?
false
end
end
class FalseClass #:nodoc:
class FalseClass
# +false+ is not duplicable:
#
# false.duplicable? # => false
# false.dup # => TypeError: can't dup FalseClass
#
def duplicable?
false
end
end
class TrueClass #:nodoc:
class TrueClass
# +true+ is not duplicable:
#
# true.duplicable? # => false
# true.dup # => TypeError: can't dup TrueClass
#
def duplicable?
false
end
end
class Symbol #:nodoc:
class Symbol
# Symbols are not duplicable:
#
# :my_symbol.duplicable? # => false
# :my_symbol.dup # => TypeError: can't dup Symbol
#
def duplicable?
false
end
end
class Numeric #:nodoc:
class Numeric
# Numbers are not duplicable:
#
# 3.duplicable? # => false
# 3.dup # => TypeError: can't dup Fixnum
#
def duplicable?
false
end
end
class Class #:nodoc:
class Class
# Classes are not duplicable:
#
# c = Class.new # => #<Class:0x10328fd80>
# c.dup # => #<Class:0x10328fd80>
#
# Note +dup+ returned the same class object.
def duplicable?
false
end
end
class Module #:nodoc:
class Module
# Modules are not duplicable:
#
# m = Module.new # => #<Module:0x10328b6e0>
# m.dup # => #<Module:0x10328b6e0>
#
# Note +dup+ returned the same module object.
def duplicable?
false
end

@ -9,12 +9,12 @@ class Object
#
# ==== Examples
#
# Without try
# Without +try+
# @person && @person.name
# or
# @person ? @person.name : nil
#
# With try
# With +try+
# @person.try(:name)
#
# +try+ also accepts arguments and/or a block, for the method it is trying
@ -34,7 +34,19 @@ def try(*a, &b)
end
end
class NilClass #:nodoc:
class NilClass
# Instances of +NilClass+ return always +nil+.
# It becomes specially helpful when navigating through associations that may return +nil+.
#
# === Examples
#
# nil.try(:name) # => nil
#
# Without +try+
# @person && !@person.children.blank? && @person.children.first.name
#
# With +try+
# @person.try(:children).try(:first).try(:name)
def try(*args)
nil
end

@ -20,7 +20,28 @@ Note: Some features of Action View are tied to Active Record, but that doesn't m
h3. Using Action View with Rails
TODO...
For each controller there is an associated directory in the <tt>app/views</tt> directory which holds the template files that make up the views associated with that controller. These files are used to display the view that results from each controller action.
Let's take a look at what Rails does by default when creating a new resource using the scaffold generator:
<shell>
$ rails generate scaffold post
[...]
invoke scaffold_controller
create app/controllers/posts_controller.rb
invoke erb
create app/views/posts
create app/views/posts/index.html.erb
create app/views/posts/edit.html.erb
create app/views/posts/show.html.erb
create app/views/posts/new.html.erb
create app/views/posts/_form.html.erb
[...]
</shell>
There is a naming convention for views in Rails. Typically, the views share their name with the associated controller action, as you can see above.
For example, the index controller action of the <tt>posts_controller.rb</tt> will use the <tt>index.html.erb</tt> view file in the <tt>app/views/posts</tt> directory.
The complete HTML returned to the client is composed of a combination of this ERB file, a layout template that wraps it, and all the partials that the view may reference. Later on this guide you can find a more detailed documentation of each one of this three components.
h3. Using Action View outside of Rails
@ -94,9 +115,213 @@ TODO needs a screenshot? I have one - not sure where to put it.
h3. Templates, Partials and Layouts
TODO...
As mentioned before, the final HTML output is a composition of three Rails elements: +Templates+, +Partials+ and +Layouts+.
Find below a brief overview of each one of them.
TODO see http://guides.rubyonrails.org/layouts_and_rendering.html
h4. Templates
Action View templates can be written in several ways. If the template file has a <tt>.erb</tt> extension then it uses a mixture of ERB (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> extension then a fresh instance of <tt>Builder::XmlMarkup</tt> library is used.
Rails supports multiple template systems and uses a file extension to distinguish amongst them. For example, an HTML file using the ERB template system will have <tt>.html.erb</tt> as a file extension.
h5. ERB
Within an ERB template Ruby code can be included using both +<% %>+ and +<%= %>+ tags. The +<% %>+ are used to execute Ruby code that does not return anything, such as conditions, loops or blocks, and the +<%= %>+ tags are used when you want output.
Consider the following loop for names:
<erb>
<b>Names of all the people</b>
<% @people.each do |person| %>
Name: <%= person.name %><br/>
<% end %>
</erb>
The loop is setup in regular embedding tags +<% %>+ and the name is written using the output embedding tag +<%= %>+. Note that this is not just a usage suggestion, for Regular output functions like print or puts won't work with ERB templates. So this would be wrong:
<erb>
<%# WRONG %>
Hi, Mr. <% puts "Frodo" %>
</erb>
To suppress leading and trailing whitespaces, you can use +<%-+ +-%>+ interchangeably with +<%+ and +%>+.
h5. Builder
Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object named +xml+ is automatically made available to templates with a <tt>.builder</tt> extension.
Here are some basic examples:
<ruby>
xml.em("emphasized")
xml.em { xml.b("emph & bold") }
xml.a("A Link", "href"=>"http://rubyonrails.org")
xml.target("name"=>"compile", "option"=>"fast")
</ruby>
will produce
<html>
<em>emphasized</em>
<em><b>emph &amp; bold</b></em>
<a href="http://rubyonrails.org">A link</a>
<target option="fast" name="compile" \>
</html>
Any method with a block will be treated as an XML markup tag with nested markup in the block. For example, the following:
<ruby>
xml.div {
xml.h1(@person.name)
xml.p(@person.bio)
}
</ruby>
would produce something like:
<html>
<div>
<h1>David Heinemeier Hansson</h1>
<p>A product of Danish Design during the Winter of '79...</p>
</div>
</html>
A full-length RSS example actually used on Basecamp:
<ruby>
xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
xml.channel do
xml.title(@feed_title)
xml.link(@url)
xml.description "Basecamp: Recent items"
xml.language "en-us"
xml.ttl "40"
for item in @recent_items
xml.item do
xml.title(item_title(item))
xml.description(item_description(item)) if item_description(item)
xml.pubDate(item_pubDate(item))
xml.guid(@person.firm.account.url + @recent_items.url(item))
xml.link(@person.firm.account.url + @recent_items.url(item))
xml.tag!("dc:creator", item.author_name) if item_has_creator?(item)
end
end
end
end
</ruby>
h5. Template caching
By default, Rails will compile each template to a method in order to render it. When you alter a template, Rails will check the file's modification time and recompile it in development mode.
h4. Partials
Partial templates usually just called "partials" are another device for breaking the rendering process into more manageable chunks. With a partial, you can move the code for rendering a particular piece of a response to its own file.
h5. Naming Partials
To render a partial as part of a view, you use the +render+ method within the view:
<ruby>
<%= render "menu" %>
</ruby>
This will render a file named +_menu.html.erb+ at that point within the view is being rendered. Note the leading underscore character: partials are named with a leading underscore to distinguish them from regular views, even though they are referred to without the underscore. This holds true even when you're pulling in a partial from another folder:
<ruby>
<%= render "shared/menu" %>
</ruby>
That code will pull in the partial from +app/views/shared/_menu.html.erb+.
h5. Using Partials to Simplify Views
One way to use partials is to treat them as the equivalent of subroutines: as a way to move details out of a view so that you can grasp what's going on more easily. For example, you might have a view that looked like this:
<erb>
<%= render "shared/ad_banner" %>
<h1>Products</h1>
<p>Here are a few of our fine products:</p>
<% @products.each do |product| %>
<%= render :partial => "product", :locals => { :product => product } %>
<% end %>
<%= render "shared/footer" %>
</erb>
Here, the +_ad_banner.html.erb+ and +_footer.html.erb+ partials could contain content that is shared among many pages in your application. You don't need to see the details of these sections when you're concentrating on a particular page.
h5. The :as and :object options
By default <tt>ActionView::Partials::PartialRenderer</tt> has its object in a local variable with the same name as the template. So, given
<erb>
<%= render :partial => "product" %>
</erb>
within product we'll get <tt>@product</tt> in the local variable +product+, as if we had written:
<erb>
<%= render :partial => "product", :locals => { :product => @product } %>
</erb>
With the <tt>:as</tt> option we can specify a different name for said local variable. For example, if we wanted it to be +item+ instead of product+ we'd do:
<erb>
<%= render :partial => "product", :as => 'item' %>
</erb>
The <tt>:object</tt> option can be used to directly specify which object is rendered into the partial; useful when the template's object is elsewhere, in a different ivar or in a local variable for instance.
For example, instead of:
<erb>
<%= render :partial => "product", :locals => { :product => @item } %>
</erb>
you'd do:
<erb>
<%= render :partial => "product", :object => @item %>
</erb>
The <tt>:object</tt> and <tt>:as</tt> options can be used together.
h5. Rendering Collections
The example of partial use describes a familiar pattern where a template needs to iterate over an array and render a sub template for each of the elements. This pattern has been implemented as a single method that accepts an array and renders a partial by the same name as the elements contained within.
So the three-lined example for rendering all the products can be rewritten with a single line:
<erb>
<%= render :partial => "product", :collection => @products %>
</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.
You can use a shorthand syntax for rendering collections. Assuming @products is a collection of +Product+ instances, you can simply write the following to produce the same result:
<erb>
<%= render @products %>
</erb>
Rails determines the name of the partial to use by looking at the model name in the collection. In fact, you can even create a heterogeneous collection and render it this way, and Rails will choose the proper partial for each member of the collection.
h5. Spacer Templates
You can also specify a second partial to be rendered between instances of the main partial by using the +:spacer_template+ option:
<erb>
<%= render @products, :spacer_template => "product_ruler" %>
</erb>
Rails will render the +_product_ruler+ partial (with no data passed in to it) between each pair of +_product+ partials.
h4. Layouts
TODO...
h3. Using Templates, Partials and Layouts in "The Rails Way"
@ -1472,5 +1697,6 @@ You can read more about the Rails Internationalization (I18n) API "here":i18n.ht
h3. Changelog
* April 16, 2011: Added 'Using Action View with Rails', 'Templates' and 'Partials' sections. "Sebastian Martinez":http://wyeworks.com
* September 3, 2009: Continuing work by Trevor Turk, leveraging the Action Pack docs and "What's new in Edge Rails":http://ryandaigle.com/articles/2007/8/3/what-s-new-in-edge-rails-partials-get-layouts
* April 5, 2009: Starting work by Trevor Turk, leveraging Mike Gunderloy's docs

@ -552,6 +552,21 @@ class Account < ActiveRecord::Base
end
</ruby>
h4. Grouping conditional validations
Sometimes it is useful to have multiple validations use one condition, it can be easily achieved using +with_options+.
<ruby>
class User < ActiveRecord::Base
with_options :if => :is_admin? do |admin|
admin.validates_length_of :password, :minimum => 10
admin.validates_presence_of :email
end
end
</ruby>
All validations inside of +with_options+ block will have automatically passed the condition +:if => :is_admin?+
h3. Creating Custom Validation Methods
When the built-in validation helpers are not enough for your needs, you can write your own validation methods.

@ -442,9 +442,9 @@ require_library_or_gem('mysql')
NOTE: Defined in +active_support/core_ext/kernel/requires.rb+.
h4. +in?+ and +either?+
h4. +in?+
The predicate +in?+ tests if an object is included in another object, and the predicate +either?+ tests if an object is included in a list of objects which will be passed as arguments.
The predicate +in?+ tests if an object is included in another object. An +ArgumentError+ exception will be raised if the argument passed does not respond to +include?+.
Examples of +in?+:
@ -454,14 +454,6 @@ Examples of +in?+:
25.in?(30..50) # => false
</ruby>
Examples of +either?+:
<ruby>
1.either?(1,2,3) # => true
5.either?(1,2,3) # => false
[1,2,3].either?([1,2,3], 2, [3,4,5]) # => true
</ruby>
NOTE: Defined in +active_support/core_ext/object/inclusion.rb+.
h3. Extensions to +Module+

@ -322,7 +322,7 @@ You can use Hashes and Arrays of values as cache keys.
<ruby>
# This is a legal cache key
Rails.cache.read(:site => "mysite", :owners => [owner_1, owner2])
Rails.cache.read(:site => "mysite", :owners => [owner_1, owner_2])
</ruby>
The keys you use on +Rails.cache+ will not be the same as those actually used with the storage engine. They may be modified with a namespace or altered to fit technology backend constraints. This means, for instance, that you can't save values with +Rails.cache+ and then try to pull them out with the +memcache-client+ gem. However, you also don't need to worry about exceeding the memcached size limit or violating syntax rules.

@ -8,10 +8,10 @@ Rails comes with every command line tool you'll need to
* Mess with objects through an interactive shell
* Profile and benchmark your new creation
NOTE: This tutorial assumes you have basic Rails knowledge from reading the "Getting Started with Rails Guide":getting_started.html.
endprologue.
NOTE: This tutorial assumes you have basic Rails knowledge from reading the "Getting Started with Rails Guide":getting_started.html.
WARNING. This Guide is based on Rails 3.0. Some of the code shown here will not work in earlier versions of Rails.
h3. Command Line Basics
@ -144,10 +144,13 @@ $ rails generate controller Greetings hello
create app/helpers/greetings_helper.rb
invoke test_unit
create test/unit/helpers/greetings_helper_test.rb
invoke assets
create app/assets/javascripts/greetings.js
create app/assets/stylesheets/greetings.css
</shell>
What all did this generate? It made sure a bunch of directories were in our application, and created a controller file, a functional test file, a helper for the view, and a view file.
What all did this generate? It made sure a bunch of directories were in our application, and created a controller file, a view file, a functional test file, a helper for the view, a javascript file and a stylesheet file.
Check out the controller and modify it a little (in +app/controllers/greetings_controller.rb+):

@ -314,14 +314,20 @@ You should not be the only person who looks at the code before you submit it. Yo
You might also want to check out the "RailsBridge BugMash":http://wiki.railsbridge.org/projects/railsbridge/wiki/BugMash as a way to get involved in a group effort to improve Rails. This can help you get started and help check your code when you're writing your first patches.
h4. Create a Lighthouse Ticket
Now create a ticket for your patch. Go to the "new ticket":http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/new page at Lighthouse. Fill in a reasonable title and description, as well as tag the ticket with the patch tag and whatever other subject area tags make sense. Write down your ticket number, for you will need it in the following step.
h4. Commit Your Changes
When you're happy with the code on your computer, you need to commit the changes to git:
<shell>
$ git commit -a -m "Here is a commit message"
$ git commit -a -m "Here is a commit message [#ticket_number state:committed]"
</shell>
NOTE: By adding '[#ticket_number state:committed]' at the end of your commit message, the ticket will automatically change its status to commited once your patch is pushed to the repository.
h4. Update master
Its pretty likely that other changes to master have happened while you were working. Go get them:
@ -361,13 +367,12 @@ $ git apply --check my_new_patch.diff
Please make sure the patch does not introduce whitespace errors:
<shell>
$ git apply --whitespace=error-all mynew_patch.diff
$ git apply --whitespace=error-all my_new_patch.diff
</shell>
h4. Attach your Patch to the Lighthouse Ticket
h4. Create a Lighthouse Ticket
Now create a ticket with your patch. Go to the "new ticket":http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/new page at Lighthouse. Fill in a reasonable title and description, remember to attach your patch file, and tag the ticket with the patch tag and whatever other subject area tags make sense.
Now you need to update the ticket by attaching the patch file you just created.
h4. Get Some Feedback
@ -385,6 +390,7 @@ All contributions, either via master or docrails, get credit in "Rails Contribut
h3. Changelog
* April 14, 2001: Modified Contributing to the Rails Code section to add '[#ticket_number state:commited]' on patches commit messages by "Sebastian Martinez":http://wyeworks.com
* December 28, 2010: Complete revision by "Xavier Noria":credits.html#fxn
* April 6, 2010: Fixed document to validate XHTML 1.0 Strict. "Jaime Iniesta":http://jaimeiniesta.com
* August 1, 2009: Updates/amplifications by "Mike Gunderloy":credits.html#mgunderloy

@ -308,6 +308,41 @@ If you repeat the +list+ command, this time using just +l+, the next ten lines o
And so on until the end of the current file. When the end of file is reached, the +list+ command will start again from the beginning of the file and continue again up to the end, treating the file as a circular buffer.
On the other hand, to see the previous ten lines you should type +list-+ (or +l-+)
<shell>
(rdb:7) l-
[1, 10] in /PathToProject/posts_controller.rb
1 class PostsController < ApplicationController
2 # GET /posts
3 # GET /posts.xml
4 def index
5 debugger
6 @posts = Post.all
7
8 respond_to do |format|
9 format.html # index.html.erb
10 format.xml { render :xml => @posts }
</shell>
This way you can move inside the file, being able to see the code above and over the line you added the +debugger+.
Finally, to see where you are in the code again you can type +list=+
<shell>
(rdb:7) list=
[1, 10] in /PathToProject/posts_controller.rb
1 class PostsController < ApplicationController
2 # GET /posts
3 # GET /posts.xml
4 def index
5 debugger
=> 6 @posts = Post.all
7
8 respond_to do |format|
9 format.html # index.html.erb
10 format.xml { render :xml => @posts }
</shell>
h4. The Context
When you start debugging your application, you will be placed in different contexts as you go through the different parts of the stack.

@ -190,7 +190,7 @@ $ rails generate scaffold User name:string
invoke test_unit
create test/unit/helpers/users_helper_test.rb
invoke stylesheets
create app/assets/stylesheets/scaffold.css.scss
create app/assets/stylesheets/scaffold.css
</shell>
Looking at this output, it's easy to understand how generators work in Rails 3.0 and above. The scaffold generator doesn't actually generate anything, it just invokes others to do the work. This allows us to add/replace/remove any of those invocations. For instance, the scaffold generator invokes the scaffold_controller generator, which invokes erb, test_unit and helper generators. Since each generator has a single responsibility, they are easy to reuse, avoiding code duplication.

@ -520,7 +520,7 @@ I18n.t 'activerecord.errors.messages'
h5. "Lazy" Lookup
Rails 2.3 implements a convenient way to look up the locale inside _views_. When you have the following dictionary:
Rails implements a convenient way to look up the locale inside _views_. When you have the following dictionary:
<yaml>
es:
@ -863,7 +863,7 @@ If you find anything missing or wrong in this guide, please file a ticket on our
h3. Contributing to Rails I18n
I18n support in Ruby on Rails was introduced in the release 2.2 and is still evolving. The project follows the good Ruby on Rails development tradition of evolving solutions in plugins and real applications first, and only then cherry-picking the best-of-bread of most widely useful features for inclusion in the core.
I18n support in Ruby on Rails was introduced in the release 2.2 and is still evolving. The project follows the good Ruby on Rails development tradition of evolving solutions in plugins and real applications first, and only then cherry-picking the best-of-breed of most widely useful features for inclusion in the core.
Thus we encourage everybody to experiment with new ideas and features in plugins or other libraries and make them available to the community. (Don't forget to announce your work on our "mailing list":http://groups.google.com/group/rails-i18n!)

@ -17,7 +17,7 @@ Ruby on Rails Guides
<% else %>
<p>
These are the new guides for Rails 3. The guides for Rails 2.3 are still available
at <a href="http://guides.rubyonrails.org/v2.3.8/">http://guides.rubyonrails.org/v2.3.8/</a>.
at <a href="http://guides.rubyonrails.org/v2.3.11/">http://guides.rubyonrails.org/v2.3.11/</a>.
</p>
<% end %>
<p>

@ -592,7 +592,11 @@ This file defines the behavior of the +ActiveSupport::Deprecation+ module, setti
h4. +activesupport/lib/active_support/notifications.rb+
TODO: document +ActiveSupport::Notifications+.
This file defines the +ActiveSupport::Notifications+ module. Notifications provides an instrumentation API for Ruby, shipping with a queue implementation that consumes and publish events to log subscribers in a thread.
The "API documentation":http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html for +ActiveSupport::Notifications+ explains the usage of this module, including the methods that it defines.
The file required in +active_support/notifications.rb+ is +active_support/core_ext/module/delegation+ which is documented in the "Active Support Core Extensions Guide":http://guides.rubyonrails.org/active_support_core_extensions.html#method-delegation.
h4. +activesupport/core_ext/array/wrap+