From fa1ba5bd5bbcdfc82104a2b88fb25d2f3695a525 Mon Sep 17 00:00:00 2001 From: Jaime Iniesta Date: Thu, 26 Aug 2010 09:55:26 +0200 Subject: lifecycle should be two words, life cycle --- railties/guides/source/association_basics.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 079bb4b6b2..b3735c270e 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -1760,9 +1760,9 @@ If you want to assign an object to a +has_and_belongs_to_many+ association witho h4. Association Callbacks -Normal callbacks hook into the lifecycle of Active Record objects, allowing you to work with those objects at various points. For example, you can use a +:before_save+ callback to cause something to happen just before an object is saved. +Normal callbacks hook into the life cycle of Active Record objects, allowing you to work with those objects at various points. For example, you can use a +:before_save+ callback to cause something to happen just before an object is saved. -Association callbacks are similar to normal callbacks, but they are triggered by events in the lifecycle of a collection. There are four available association callbacks: +Association callbacks are similar to normal callbacks, but they are triggered by events in the life cycle of a collection. There are four available association callbacks: * +before_add+ * +after_add+ -- cgit v1.2.3 From 0f9eedf6de72f4afacde6d7075c588a7a6fd3ad6 Mon Sep 17 00:00:00 2001 From: Jaime Iniesta Date: Thu, 26 Aug 2010 10:16:08 +0200 Subject: change 'a SQL' to 'an SQL' as suggested by the api documentation guidelines --- .../source/active_record_validations_callbacks.textile | 4 ++-- railties/guides/source/association_basics.textile | 14 +++++++------- railties/guides/source/migrations.textile | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 1e232422e3..9bdeecb684 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -57,7 +57,7 @@ We can see how it works by looking at some +rails console+ output: => false -Creating and saving a new record will send a SQL +INSERT+ operation to the database. Updating an existing record will send a SQL +UPDATE+ operation instead. Validations are typically run before these commands are sent to the database. If any validations fail, the object will be marked as invalid and Active Record will not perform the +INSERT+ or +UPDATE+ operation. This helps to avoid storing an invalid object in the database. You can choose to have specific validations run when an object is created, saved, or updated. +Creating and saving a new record will send an SQL +INSERT+ operation to the database. Updating an existing record will send an SQL +UPDATE+ operation instead. Validations are typically run before these commands are sent to the database. If any validations fail, the object will be marked as invalid and Active Record will not perform the +INSERT+ or +UPDATE+ operation. This helps to avoid storing an invalid object in the database. You can choose to have specific validations run when an object is created, saved, or updated. CAUTION: There are many ways to change the state of an object in the database. Some methods will trigger validations, but some will not. This means that it's possible to save an object in the database in an invalid state if you aren't careful. @@ -382,7 +382,7 @@ class Account < ActiveRecord::Base end -The validation happens by performing a SQL query into the model's table, searching for an existing record with the same value in that attribute. +The validation happens by performing an SQL query into the model's table, searching for an existing record with the same value in that attribute. There is a +:scope+ option that you can use to specify other attributes that are used to limit the uniqueness check: diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index b3735c270e..17742a8d8c 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -629,7 +629,7 @@ end h6(#belongs_to-conditions). +:conditions+ -The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by a SQL +WHERE+ clause). +The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by an SQL +WHERE+ clause). class Order < ActiveRecord::Base @@ -899,7 +899,7 @@ end h6(#has_one-conditions). +:conditions+ -The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by a SQL +WHERE+ clause). +The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by an SQL +WHERE+ clause). class Supplier < ActiveRecord::Base @@ -961,7 +961,7 @@ end h6(#has_one-order). +:order+ -The +:order+ option dictates the order in which associated objects will be received (in the syntax used by a SQL +ORDER BY+ clause). Because a +has_one+ association will only retrieve a single associated object, this option should not be needed. +The +:order+ option dictates the order in which associated objects will be received (in the syntax used by an SQL +ORDER BY+ clause). Because a +has_one+ association will only retrieve a single associated object, this option should not be needed. h6(#has_one-primary_key). +:primary_key+ @@ -1209,7 +1209,7 @@ end h6(#has_many-conditions). +:conditions+ -The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by a SQL +WHERE+ clause). +The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by an SQL +WHERE+ clause). class Customer < ActiveRecord::Base @@ -1335,7 +1335,7 @@ The +:offset+ option lets you specify the starting offset for fetching objects v h6(#has_many-order). +:order+ -The +:order+ option dictates the order in which associated objects will be received (in the syntax used by a SQL +ORDER BY+ clause). +The +:order+ option dictates the order in which associated objects will be received (in the syntax used by an SQL +ORDER BY+ clause). class Customer < ActiveRecord::Base @@ -1635,7 +1635,7 @@ end h6(#has_and_belongs_to_many-conditions). +:conditions+ -The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by a SQL +WHERE+ clause). +The +:conditions+ option lets you specify the conditions that the associated object must meet (in the syntax used by an SQL +WHERE+ clause). class Parts < ActiveRecord::Base @@ -1724,7 +1724,7 @@ The +:offset+ option lets you specify the starting offset for fetching objects v h6(#has_and_belongs_to_many-order). +:order+ -The +:order+ option dictates the order in which associated objects will be received (in the syntax used by a SQL +ORDER BY+ clause). +The +:order+ option dictates the order in which associated objects will be received (in the syntax used by an SQL +ORDER BY+ clause). class Parts < ActiveRecord::Base diff --git a/railties/guides/source/migrations.textile b/railties/guides/source/migrations.textile index 16f616a5bc..89aa007279 100644 --- a/railties/guides/source/migrations.textile +++ b/railties/guides/source/migrations.textile @@ -250,7 +250,7 @@ create_table :products do |t| end -By default +create_table+ will create a primary key called +id+. You can change the name of the primary key with the +:primary_key+ option (don't forget to update the corresponding model) or if you don't want a primary key at all (for example for a HABTM join table) you can pass +:id => false+. If you need to pass database specific options you can place a SQL fragment in the +:options+ option. For example +By default +create_table+ will create a primary key called +id+. You can change the name of the primary key with the +:primary_key+ option (don't forget to update the corresponding model) or if you don't want a primary key at all (for example for a HABTM join table) you can pass +:id => false+. If you need to pass database specific options you can place an SQL fragment in the +:options+ option. For example create_table :products, :options => "ENGINE=BLACKHOLE" do |t| -- cgit v1.2.3 From 8e3d23dea207ebe531de7a1ad9ad9151c3936894 Mon Sep 17 00:00:00 2001 From: James Miller Date: Thu, 26 Aug 2010 09:55:18 -0700 Subject: Link to gembundler.com instead of Github repo --- railties/guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index d9525539ab..dfc31a0f34 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -194,7 +194,7 @@ In any case, Rails will create a folder in your working directory called blo h4. Installing the Required Gems -Rails applications manage gem dependencies with "Bundler":http://www.github.com/carlhuda/bundler by default. As we don't need any other gems beyond the ones in the generated +Gemfile+ we can directly run +Rails applications manage gem dependencies with "Bundler":http://gembundler.com/v1.0/index.html by default. As we don't need any other gems beyond the ones in the generated +Gemfile+ we can directly run bundle install -- cgit v1.2.3 From a88fb2fd1b2521c3bed02d97805ae7a83eb975df Mon Sep 17 00:00:00 2001 From: James Miller Date: Thu, 26 Aug 2010 10:00:11 -0700 Subject: Getting started guide: typo --- railties/guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index dfc31a0f34..dc60377e34 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -320,7 +320,7 @@ $ rm public/index.html We need to do this as Rails will deliver any static file in the +public+ directory in preference to any dynamic contact we generate from the controllers. -Now, you have to tell Rails where your actual home page is located. Open the file +config/routes.rb+ in your editor. This is your application's _routing file_ which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with +:root to+, uncomment it and change it like the following: +Now, you have to tell Rails where your actual home page is located. Open the file +config/routes.rb+ in your editor. This is your application's _routing file_ which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with +root :to+, uncomment it and change it like the following: Blog::Application.routes.draw do -- cgit v1.2.3 From 2bcac56ab4059356f9f1a0f0d970fd3c9d225f65 Mon Sep 17 00:00:00 2001 From: James Miller Date: Thu, 26 Aug 2010 12:10:21 -0700 Subject: Prefer modern idiom for rendering partials on a collection --- railties/guides/source/getting_started.textile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index dc60377e34..48393d2156 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -1056,8 +1056,7 @@ Then in the +app/views/posts/show.html.erb+ you can change it to look like the f

Comments

-<%= render :partial => "comments/comment", - :collection => @post.comments %> +<%= render @post.comments %>

Add a comment:

<%= form_for([@post, @post.comments.build]) do |f| %> @@ -1127,8 +1126,7 @@ Then you make the +app/views/posts/show.html.erb+ look like the following:

Comments

-<%= render :partial => "comments/comment", - :collection => @post.comments %> +<%= render @post.comments %>

Add a comment:

<%= render "comments/form" %> @@ -1381,8 +1379,7 @@ Finally, we will edit the app/views/posts/show.html.erb template to sho

Comments

-<%= render :partial => "comments/comment", - :collection => @post.comments %> +<%= render @post.comments %>

Add a comment:

<%= render "comments/form" %> @@ -1436,8 +1433,7 @@ Now you can edit the view in app/views/posts/show.html.erb to look like

Comments

-<%= render :partial => "comments/comment", - :collection => @post.comments %> +<%= render @post.comments %>

Add a comment:

<%= render "comments/form" %> -- cgit v1.2.3 From 0631bf4baf463a0e8ca74c56a21ed0b320d254d0 Mon Sep 17 00:00:00 2001 From: James Miller Date: Thu, 26 Aug 2010 12:27:44 -0700 Subject: Simplify render :partial --- railties/guides/source/action_view_overview.textile | 2 +- railties/guides/source/performance_testing.textile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index e242cdaf73..459d70f111 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -428,7 +428,7 @@ A method for caching fragments of a view rather than an entire action or page. T <% cache do %> - <%= render :partial => "shared/footer" %> + <%= render "shared/footer" %> <% end %> diff --git a/railties/guides/source/performance_testing.textile b/railties/guides/source/performance_testing.textile index 65f8d07e7a..7b21485ea0 100644 --- a/railties/guides/source/performance_testing.textile +++ b/railties/guides/source/performance_testing.textile @@ -469,7 +469,7 @@ And in "views":http://api.rubyonrails.org/classes/ActionController/Benchmarking/ <% benchmark("Showing projects partial") do %> - <%= render :partial => @projects %> + <%= render @projects %> <% end %> -- cgit v1.2.3 From 4d8158d9e5ada4aff5dc62712b7c4730b60cde48 Mon Sep 17 00:00:00 2001 From: Jamison Dance Date: Thu, 26 Aug 2010 17:48:42 -0600 Subject: fix sentence fragment in validates_associated caution --- railties/guides/source/active_record_validations_callbacks.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 1e232422e3..2601a8fbcf 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -197,7 +197,7 @@ end This validation will work with all of the association types. -CAUTION: Don't use +validates_associated+ on both ends of your associations, they would call each other in an infinite loop. +CAUTION: Don't use +validates_associated+ on both ends of your associations. They would call each other in an infinite loop. The default error message for +validates_associated+ is "_is invalid_". Note that each associated object will contain its own +errors+ collection; errors do not bubble up to the calling model. -- cgit v1.2.3