aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/base.rb5
-rw-r--r--activerecord/lib/active_record/persistence.rb8
-rw-r--r--railties/guides/source/getting_started.textile2
3 files changed, 13 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index d53a0c2609..4bbf5cd3d1 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -876,6 +876,11 @@ module ActiveRecord #:nodoc:
# limit(10) # Fires "SELECT * FROM posts LIMIT 10"
# }
#
+ # It is recommended to use block form of unscoped because chaining unscoped with <tt>named_scope</tt>
+ # does not work. Assuming that <tt>published</tt> is a <tt>named_scope</tt> following two statements are same.
+ #
+ # Post.unscoped.published
+ # Post.published
def unscoped
block_given? ? relation.scoping { yield } : relation
end
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index c5c40d1863..1ce86da2fa 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -208,10 +208,14 @@ module ActiveRecord
# If an attribute name is passed, that attribute is updated along with
# updated_at/on attributes.
#
- # Examples:
- #
# product.touch # updates updated_at/on
# product.touch(:designed_at) # updates the designed_at attribute and updated_at/on
+ #
+ # If used along with +belongs_to+ then +touch+ will invoke +touch+ method on associated object.
+ #
+ # Brake.belongs_to :car, :touch => true
+ # Car.belongs_to :corporation, :touch => true
+ # @brake.touch #=> will also invoke @brake.car.touch and @brake.car.corporation.touch
def touch(name = nil)
attributes = timestamp_attributes_for_update_in_model
unless attributes.blank?
diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile
index e68a82e9db..c292daa915 100644
--- a/railties/guides/source/getting_started.textile
+++ b/railties/guides/source/getting_started.textile
@@ -488,6 +488,8 @@ After the console loads, you can use it to work with your application's models:
This code shows creating a new +Post+ instance, attempting to save it and getting +false+ for a return value (indicating that the save failed), and inspecting the +errors+ of the post.
+When you're finished, type +exit+ and hit +return+ to exit the console.
+
TIP: Unlike the development web server, the console does not automatically load your code afresh for each line. If you make changes to your models while the console is open, type +reload!+ at the console prompt to load them.
h4. Listing All Posts