aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides
diff options
context:
space:
mode:
authorAvi Tzurel <avi@kensodev.com>2012-03-12 12:03:57 +0200
committerAvi Tzurel <avi@kensodev.com>2012-03-12 12:03:57 +0200
commit78954acde740716746959aa77c5c0b103789f2e4 (patch)
treef96afc78c6725131551094301a43bd86dee9fea8 /railties/guides
parent8de49fe4613ee4362385dd69d984da463d195a7e (diff)
parent36bd5c97420e46a19658e34dbe24bcab265311af (diff)
downloadrails-78954acde740716746959aa77c5c0b103789f2e4.tar.gz
rails-78954acde740716746959aa77c5c0b103789f2e4.tar.bz2
rails-78954acde740716746959aa77c5c0b103789f2e4.zip
Merge remote-tracking branch 'original_repo/master'
Diffstat (limited to 'railties/guides')
-rw-r--r--railties/guides/source/2_2_release_notes.textile2
-rw-r--r--railties/guides/source/active_support_core_extensions.textile49
-rw-r--r--railties/guides/source/active_support_instrumentation.textile57
-rw-r--r--railties/guides/source/documents.yaml4
-rw-r--r--railties/guides/source/form_helpers.textile4
-rw-r--r--railties/guides/source/security.textile2
6 files changed, 65 insertions, 53 deletions
diff --git a/railties/guides/source/2_2_release_notes.textile b/railties/guides/source/2_2_release_notes.textile
index 8e2d528eee..3a0f2efbaf 100644
--- a/railties/guides/source/2_2_release_notes.textile
+++ b/railties/guides/source/2_2_release_notes.textile
@@ -229,7 +229,7 @@ This will enable recognition of (among others) these routes:
* Lead Contributor: "S. Brent Faulkner":http://www.unwwwired.net/
* More information:
-** "Rails Routing from the Outside In":http://guides.rubyonrails.org/routing.html#_nested_resources
+** "Rails Routing from the Outside In":http://guides.rubyonrails.org/routing.html#nested-resources
** "What's New in Edge Rails: Shallow Routes":http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-shallow-routes
h4. Method Arrays for Member or Collection Routes
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 2091ce0395..5d0a3f82e8 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -509,55 +509,6 @@ end
NOTE: Defined in +active_support/core_ext/module/aliasing.rb+.
-h5. +attr_accessor_with_default+
-
-The method +attr_accessor_with_default+ serves the same purpose as the Ruby macro +attr_accessor+ but allows you to set a default value for the attribute:
-
-<ruby>
-class Url
- attr_accessor_with_default :port, 80
-end
-
-Url.new.port # => 80
-</ruby>
-
-The default value can be also specified with a block, which is called in the context of the corresponding object:
-
-<ruby>
-class User
- attr_accessor :name, :surname
- attr_accessor_with_default(:full_name) do
- [name, surname].compact.join(" ")
- end
-end
-
-u = User.new
-u.name = 'Xavier'
-u.surname = 'Noria'
-u.full_name # => "Xavier Noria"
-</ruby>
-
-The result is not cached, the block is invoked in each call to the reader.
-
-You can overwrite the default with the writer:
-
-<ruby>
-url = Url.new
-url.host # => 80
-url.host = 8080
-url.host # => 8080
-</ruby>
-
-The default value is returned as long as the attribute is unset. The reader does not rely on the value of the attribute to know whether it has to return the default. It rather monitors the writer: if there's any assignment the value is no longer considered to be unset.
-
-Active Resource uses this macro to set a default value for the +:primary_key+ attribute:
-
-<ruby>
-attr_accessor_with_default :primary_key, 'id'
-</ruby>
-
-NOTE: Defined in +active_support/core_ext/module/attr_accessor_with_default.rb+.
-
h5. Internal Attributes
When you are defining an attribute in a class that is meant to be subclassed, name collisions are a risk. That's remarkably important for libraries.
diff --git a/railties/guides/source/active_support_instrumentation.textile b/railties/guides/source/active_support_instrumentation.textile
index f9452400ad..8e2866dfc3 100644
--- a/railties/guides/source/active_support_instrumentation.textile
+++ b/railties/guides/source/active_support_instrumentation.textile
@@ -21,10 +21,67 @@ You are even able to create your own events inside your application which you ca
h3. Rails framework hooks
+Within the Ruby on Rails framework, there are a number of hooks provided for common events. These are detailed below.
+
h4. Action Mailer
+h5. receive.action_mailer
+
+This hook is called when the +receive+ method of an +ActionMailer::Base+ class is called:
+
+<ruby>
+ class Mailer < ActionMailer::Base
+ def receive(mail)
+
+ end
+ end
+</ruby>
+
+The payload for this event has the following parameters related to the incoming email:
+
+|_.Key |_.Value|
+|mailer |Name of the mailer class|
+|message_id |ID of the message, generated by the Mail gem|
+|subject |Subject of the mail|
+|to |To address(es) of the mail|
+|from |From address of the mail|
+|bcc |BCC addresses of the mail|
+|cc |CC addresses of the mail|
+|date |Date of the mail|
+|mail |The encoded form of the mail|
+
+h5. deliver.action_mailer
+
+This hook is called when the +deliver+ method is called on a +Mail::Message+ object. This is due to a hook inserted by Action Mailer, rather than a specific feature of the Mail gem itself.
+
+The payload for this event has the following parameters related to the outgoing email:
+
+|_.Key |_.Value|
+|mailer |Name of the mailer class|
+|message_id |ID of the message, generated by the Mail gem|
+|subject |Subject of the mail|
+|to |To address(es) of the mail|
+|from |From address of the mail|
+|bcc |BCC addresses of the mail|
+|cc |CC addresses of the mail|
+|date |Date of the mail|
+|mail |The encoded form of the mail|
+
+
h4. Action Controller
+h5. write_fragment.action_controller
+
+h5. read_fragment.action_controller
+
+h5. exist_fragment?.action_controller
+
+h5. expire_fragment.action_controller
+
+h5. write_page.action_controller
+
+h5. expire_page.action_controller
+
h4. Action View
h4. Active Record
diff --git a/railties/guides/source/documents.yaml b/railties/guides/source/documents.yaml
index 08aafda288..1c8d7d284c 100644
--- a/railties/guides/source/documents.yaml
+++ b/railties/guides/source/documents.yaml
@@ -97,6 +97,10 @@
url: asset_pipeline.html
description: This guide documents the asset pipeline.
-
+ name: Getting Started with Engines
+ url: engines.html
+ description: This guide explains how to write a mountable engine.
+ -
name: The Rails Initialization Process
work_in_progress: true
url: initialization.html
diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile
index a696e4f8ae..9f91d12a54 100644
--- a/railties/guides/source/form_helpers.textile
+++ b/railties/guides/source/form_helpers.textile
@@ -39,7 +39,7 @@ When called without arguments like this, it creates a +&lt;form&gt;+ tag which,
</form>
</html>
-Now, you'll notice that the HTML contains something extra: a +div+ element with two hidden input elements inside. This div is important, because the form cannot be successfully submitted without it. The first input element with name +utf8+ enforces browsers to properly respect your form's character encoding and is generated for all forms whether their actions are "GET" or "POST". The second input element with name +authenticity_token+ is a security feature of Rails called *cross-site request forgery protection*, and form helpers generate it for every non-GET form (provided that this security feature is enabled). You can read more about this in the "Security Guide":./security.html#_cross_site_reference_forgery_csrf.
+Now, you'll notice that the HTML contains something extra: a +div+ element with two hidden input elements inside. This div is important, because the form cannot be successfully submitted without it. The first input element with name +utf8+ enforces browsers to properly respect your form's character encoding and is generated for all forms whether their actions are "GET" or "POST". The second input element with name +authenticity_token+ is a security feature of Rails called *cross-site request forgery protection*, and form helpers generate it for every non-GET form (provided that this security feature is enabled). You can read more about this in the "Security Guide":./security.html#cross-site-request-forgery-csrf.
NOTE: Throughout this guide, the +div+ with the hidden input elements will be excluded from code samples for brevity.
@@ -428,7 +428,7 @@ As with other helpers, if you were to use the +select+ helper on a form builder
<%= f.select(:city_id, ...) %>
</erb>
-WARNING: If you are using +select+ (or similar helpers such as +collection_select+, +select_tag+) to set a +belongs_to+ association you must pass the name of the foreign key (in the example above +city_id+), not the name of association itself. If you specify +city+ instead of +city_id+ Active Record will raise an error along the lines of <tt> ActiveRecord::AssociationTypeMismatch: City(#17815740) expected, got String(#1138750) </tt> when you pass the +params+ hash to +Person.new+ or +update_attributes+. Another way of looking at this is that form helpers only edit attributes. You should also be aware of the potential security ramifications of allowing users to edit foreign keys directly. You may wish to consider the use of +attr_protected+ and +attr_accessible+. For further details on this, see the "Ruby On Rails Security Guide":security.html#_mass_assignment.
+WARNING: If you are using +select+ (or similar helpers such as +collection_select+, +select_tag+) to set a +belongs_to+ association you must pass the name of the foreign key (in the example above +city_id+), not the name of association itself. If you specify +city+ instead of +city_id+ Active Record will raise an error along the lines of <tt> ActiveRecord::AssociationTypeMismatch: City(#17815740) expected, got String(#1138750) </tt> when you pass the +params+ hash to +Person.new+ or +update_attributes+. Another way of looking at this is that form helpers only edit attributes. You should also be aware of the potential security ramifications of allowing users to edit foreign keys directly. You may wish to consider the use of +attr_protected+ and +attr_accessible+. For further details on this, see the "Ruby On Rails Security Guide":security.html#mass-assignment.
h4. Option Tags from a Collection of Arbitrary Objects
diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile
index b1a09c0c05..747a4d6791 100644
--- a/railties/guides/source/security.textile
+++ b/railties/guides/source/security.textile
@@ -374,7 +374,7 @@ end
Mass-assignment saves you much work, because you don't have to set each value individually. Simply pass a hash to the +new+ method, or +assign_attributes=+ a hash value, to set the model's attributes to the values in the hash. The problem is that it is often used in conjunction with the parameters (params) hash available in the controller, which may be manipulated by an attacker. He may do so by changing the URL like this:
<pre>
-"name":http://www.example.com/user/signup?user[name]=ow3ned&user[admin]=1
+http://www.example.com/user/signup?user[name]=ow3ned&user[admin]=1
</pre>
This will set the following parameters in the controller: