From c9fe3c3bd0ee5010a36a157fe850ef6e8ffb147d Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 27 Jul 2010 13:55:00 -0400 Subject: [PATCH 01/20] adding comments to update_attribute method --- activerecord/lib/active_record/persistence.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index b587abd5d0..869cbf5b2e 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -110,6 +110,10 @@ module ActiveRecord # * updated_at/updated_on column is updated if that column is available # * does not work on associations # * does not work on attr_accessor attributes. The attribute that is being updated must be column name. + # * does not work on new record. record.new_record? should return false for this method to work. + # * updates only the attribute that is input to the method. If there are other changed attributes then + # those attributes are left alone. In that case even after this method has done its work record.changed? + # will return true. # def update_attribute(name, value) raise ActiveRecordError, "#{name.to_s} is marked as readonly" if self.class.readonly_attributes.include? name.to_s From e7920a3bde47f1f788fc8d6b8cb00861a78047f8 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 27 Jul 2010 16:30:56 -0400 Subject: [PATCH 02/20] clarifying description for class_attribute method --- activesupport/lib/active_support/core_ext/class/attribute.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index 576366e496..83b2695606 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -2,8 +2,8 @@ require 'active_support/core_ext/kernel/singleton_class' require 'active_support/core_ext/module/remove_method' class Class - # Declare a class-level attribute whose value is inheritable and - # overwritable by subclasses: + # Declare a class-level attribute whose value is inheritable by subclasses. + # Subclasses can change their own value and it will not impact parent class. # # class Base # class_attribute :setting From 1793b21479d29ec29bd47c37ee68cb6ebdb71617 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 27 Jul 2010 14:27:15 -0700 Subject: [PATCH 03/20] Frameworks are loaded in application.rb rather than config.rb according to Rails 3 conventions. --- activerecord/lib/active_record/railties/databases.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 2c17c74ab4..d61cc520b7 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -333,7 +333,7 @@ namespace :db do if File.exists?(file) load(file) else - abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/boot.rb to limit the frameworks that will be loaded} + abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to limit the frameworks that will be loaded} end end end From 67e79cf96d6bd27779a659703253984ac47a90ee Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 27 Jul 2010 23:31:59 +0200 Subject: [PATCH 04/20] Revert "Frameworks are loaded in application.rb rather than config.rb according to Rails 3 conventions." This reverts commit 1793b21479d29ec29bd47c37ee68cb6ebdb71617. This commit had no risk, but docrails has a hard rule about touching code. The contribution is appreciated, I hope you do not mind this technical revert. I'll apply that to master with proper credit. --- activerecord/lib/active_record/railties/databases.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index d61cc520b7..2c17c74ab4 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -333,7 +333,7 @@ namespace :db do if File.exists?(file) load(file) else - abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to limit the frameworks that will be loaded} + abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/boot.rb to limit the frameworks that will be loaded} end end end From f3b50b11c7cba1ae21888c755cbeabf3b3aca072 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 09:53:24 -0400 Subject: [PATCH 05/20] updating description of how class_attribute works --- activesupport/lib/active_support/core_ext/class/attribute.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index 83b2695606..cee3f04354 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -18,6 +18,11 @@ class Class # Subclass.setting # => false # Base.setting # => true # + # In the above case as long as Subclass does not assign a value to setting + # by performing Subclass.setting = _something_ , Subclass.setting + # would read value assigned to parent class. Once Subclass assigns a value then + # the value assigned by Subclass would be returned. + # # This matches normal Ruby method inheritance: think of writing an attribute # on a subclass as overriding the reader method. # From ff7e17d33e8042fa430fd637ef3433ef7367dc30 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 10:05:10 -0400 Subject: [PATCH 06/20] adding some comments to cattr_accessor method --- .../active_support/core_ext/class/attribute_accessors.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb index feef5d2d57..cdc7cfc1d4 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb @@ -3,11 +3,17 @@ require 'active_support/core_ext/array/extract_options' # Extends the class object with class and instance accessors for class attributes, # just like the native attr* accessors for instance attributes. # +# Note that unlike +class_attribute+, if a subclass changes the value then that would +# also change the value for parent class. Similarly if parent class changes the value +# then that would change the value of subclasses too. +# # class Person # cattr_accessor :hair_colors # end # # Person.hair_colors = [:brown, :black, :blonde, :red] +# Person.hair_colors #=> [:brown, :black, :blonde, :red] +# Person.new.hair_colors #=> [:brown, :black, :blonde, :red] class Class def cattr_reader(*syms) options = syms.extract_options! From eb902d6c00f64e7060f24fa3b243d5b6dea98cac Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 10:08:00 -0400 Subject: [PATCH 07/20] clarifying the instance_write option with an example --- .../lib/active_support/core_ext/class/attribute.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index cee3f04354..af8202ae2c 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -41,7 +41,11 @@ class Class # # To opt out of the instance writer method, pass :instance_writer => false. # - # object.setting = false # => NoMethodError + # class Base + # class_attribute :setting, :instance_write => false + # end + # + # Base.new.setting = false # => NoMethodError def class_attribute(*attrs) instance_writer = !attrs.last.is_a?(Hash) || attrs.pop[:instance_writer] From 5b10e47593ed21fedba2401e3ad1f360e2cf0706 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 10:13:11 -0400 Subject: [PATCH 08/20] adding comment specifying that cattr_accessor also supports instance_write and instance_rader option --- .../core_ext/class/attribute_accessors.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb index cdc7cfc1d4..4e35b1b488 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb @@ -14,6 +14,16 @@ require 'active_support/core_ext/array/extract_options' # Person.hair_colors = [:brown, :black, :blonde, :red] # Person.hair_colors #=> [:brown, :black, :blonde, :red] # Person.new.hair_colors #=> [:brown, :black, :blonde, :red] +# +# To opt out of the instance writer method, pass :instance_writer => false. +# To opt out of the instance reader method, pass :instance_reader => false. +# +# class Person +# cattr_accessor :hair_colors, :instance_writer => false, :instance_reader => false +# end +# +# Person.new.hair_colors = [:brown] # => NoMethodError +# Person.new.hair_colors # => NoMethodError class Class def cattr_reader(*syms) options = syms.extract_options! From 2d601e4ea30ab1e2de97c53c550b60e1c98b144a Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 10:56:10 -0400 Subject: [PATCH 09/20] editing a sentence --- activesupport/lib/active_support/cache.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 1445cec446..acf2d2bc85 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -131,7 +131,7 @@ module ActiveSupport # # All caches support auto expiring content after a specified number of seconds. # To set the cache entry time to live, you can either specify +:expires_in+ as - # an option to the constructor to have it affect all entries or to the +fetch+ + # an option to the constructor to affect all entries or to the +fetch+ # or +write+ methods for just one entry. # # cache = ActiveSupport::Cache::MemoryStore.new(:expire_in => 5.minutes) From dea8bf5dc42ea081cce1702e3a7566cbdef50a69 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 11:22:35 -0400 Subject: [PATCH 10/20] editing the documentation regarding :race_condition_ttl and :expires_in option in AS cache --- activesupport/lib/active_support/cache.rb | 45 ++++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index acf2d2bc85..037cfffae2 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -129,13 +129,6 @@ module ActiveSupport # cache.namespace = lambda { @last_mod_time } # Set the namespace to a variable # @last_mod_time = Time.now # Invalidate the entire cache by changing namespace # - # All caches support auto expiring content after a specified number of seconds. - # To set the cache entry time to live, you can either specify +:expires_in+ as - # an option to the constructor to affect all entries or to the +fetch+ - # or +write+ methods for just one entry. - # - # cache = ActiveSupport::Cache::MemoryStore.new(:expire_in => 5.minutes) - # cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry # # Caches can also store values in a compressed format to save space and reduce # time spent sending data. Since there is some overhead, values must be large @@ -211,23 +204,30 @@ module ActiveSupport # Setting :compress will store a large cache entry set by the call # in a compressed format. # - # Setting :expires_in will set an expiration time on the cache - # entry if it is set by call. # - # Setting :race_condition_ttl will invoke logic on entries set with - # an :expires_in option. If an entry is found in the cache that is - # expired and it has been expired for less than the number of seconds specified - # by this option and a block was passed to the method call, then the expiration - # future time of the entry in the cache will be updated to that many seconds - # in the and the block will be evaluated and written to the cache. + # Setting :expires_in will set an expiration time on the cache. All caches + # support auto expiring content after a specified number of seconds. This value can + # be specified as an option to the construction in which call all entries will be + # affected. Or it can be supplied to the +fetch+ or +write+ method for just one entry. # - # This is very useful in situations where a cache entry is used very frequently - # under heavy load. The first process to find an expired cache entry will then - # become responsible for regenerating that entry while other processes continue - # to use the slightly out of date entry. This can prevent race conditions where - # too many processes are trying to regenerate the entry all at once. If the - # process regenerating the entry errors out, the entry will be regenerated - # after the specified number of seconds. + # cache = ActiveSupport::Cache::MemoryStore.new(:expire_in => 5.minutes) + # cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry + # + # Setting :race_condition_ttl is very useful in situations where a cache entry + # is used very frequently unver heavy load. If a cache expires and due to heavy load + # seven different processes will try to read data natively and then they all will try to + # write to cache. To avoid that case the first process to find an expired cache entry will + # bump the cache expiration time by the value set in :race_condition_ttl. Yes + # this process is extending the time for a stale value by another few seconds. Because + # of extended life of the previous cache, other processes will continue to use slightly + # stale data for a just a big longer. In the meantime that first process will go ahead + # and will write into cache the new value. After that all the processes will start + # getting new value. The key is to keep :race_condition_ttl small. + # + # If the process regenerating the entry errors out, the entry will be regenerated + # after the specified number of seconds. Also note that the life of stale cache is + # extended only if it expired recently. Otherwise a new value is generated and + # :race_condition_ttl does not play any role. # # # Set all values to expire after one minute. # cache = ActiveSupport::Cache::MemoryCache.new(:expires_in => 1.minute) @@ -252,6 +252,7 @@ module ActiveSupport # # # val_1 => "new value 1" # # val_2 => "original value" + # # sleep 10 # First thread extend the life of cache by another 10 seconds # # cache.fetch("foo") => "new value 1" # # Other options will be handled by the specific cache store implementation. From 7c3d479c4b8ae5667ead1163d4ce713c5ae73629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 28 Jul 2010 08:49:54 -0700 Subject: [PATCH 11/20] More documentation to class_attribute. --- .../core_ext/class/attribute.rb | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index af8202ae2c..bfa57fe1f7 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -18,17 +18,34 @@ class Class # Subclass.setting # => false # Base.setting # => true # - # In the above case as long as Subclass does not assign a value to setting - # by performing Subclass.setting = _something_ , Subclass.setting - # would read value assigned to parent class. Once Subclass assigns a value then - # the value assigned by Subclass would be returned. + # In the above case as long as Subclass does not assign a value to setting + # by performing Subclass.setting = _something_ , Subclass.setting + # would read value assigned to parent class. Once Subclass assigns a value then + # the value assigned by Subclass would be returned. # # This matches normal Ruby method inheritance: think of writing an attribute - # on a subclass as overriding the reader method. + # on a subclass as overriding the reader method. However, you need to be aware + # when using +class_attribute+ with mutable structures as +Array+ or +Hash+. + # In such cases, you don't want to do changes in places but use setters: + # + # Base.setting = [] + # Base.setting #=> [] + # Subclass.setting #=> [] + # + # # Appending in child changes both parent and child because it is the same object: + # Subclass.setting << :foo + # Base.setting #=> [:foo] + # Subclass.setting #=> [:foo] + # + # # Use setters to not propagate changes: + # Base.setting = [] + # Subclass.setting += [:foo] + # Base.setting #=> [] + # Subclass.setting #=> [:foo] # # For convenience, a query method is defined as well: # - # Subclass.setting? # => false + # Subclass.setting? # => false # # Instances may overwrite the class value in the same way: # @@ -41,11 +58,7 @@ class Class # # To opt out of the instance writer method, pass :instance_writer => false. # - # class Base - # class_attribute :setting, :instance_write => false - # end - # - # Base.new.setting = false # => NoMethodError + # object.setting = false # => NoMethodError def class_attribute(*attrs) instance_writer = !attrs.last.is_a?(Hash) || attrs.pop[:instance_writer] From 51924d49af18635cab46720e208c34d75ed8363e Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 12:51:09 -0400 Subject: [PATCH 12/20] more documentation for update_attribute --- activerecord/lib/active_record/persistence.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 869cbf5b2e..36530d2b63 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -105,13 +105,14 @@ module ActiveRecord # Updates a single attribute and saves the record. # This is especially useful for boolean flags on existing records. Also note that # - # * validation is skipped + # * The attribute being updated must be a column name. + # * Validation is skipped # * No callbacks are invoked # * updated_at/updated_on column is updated if that column is available - # * does not work on associations - # * does not work on attr_accessor attributes. The attribute that is being updated must be column name. - # * does not work on new record. record.new_record? should return false for this method to work. - # * updates only the attribute that is input to the method. If there are other changed attributes then + # * Does not work on associations + # * Does not work on attr_accessor attributes. + # * Does not work on new record. record.new_record? should return false for this method to work. + # * Updates only the attribute that is input to the method. If there are other changed attributes then # those attributes are left alone. In that case even after this method has done its work record.changed? # will return true. # From 31f8a0cd23ca3d1137968e95bce47a431555bdd6 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 13:10:04 -0400 Subject: [PATCH 13/20] adding punctuations --- activerecord/lib/active_record/persistence.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 36530d2b63..38b91652ee 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -106,10 +106,10 @@ module ActiveRecord # This is especially useful for boolean flags on existing records. Also note that # # * The attribute being updated must be a column name. - # * Validation is skipped - # * No callbacks are invoked - # * updated_at/updated_on column is updated if that column is available - # * Does not work on associations + # * Validation is skipped. + # * No callbacks are invoked. + # * updated_at/updated_on column is updated if that column is available. + # * Does not work on associations. # * Does not work on attr_accessor attributes. # * Does not work on new record. record.new_record? should return false for this method to work. # * Updates only the attribute that is input to the method. If there are other changed attributes then From f46e841f7217dd839ce166ec9a592f0dec127673 Mon Sep 17 00:00:00 2001 From: Simon Tokumine Date: Wed, 28 Jul 2010 14:56:05 -0700 Subject: [PATCH 14/20] removed ambiguity from autosave description --- activerecord/lib/active_record/associations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 1b9b725dd4..f540aa7f25 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -303,7 +303,7 @@ module ActiveRecord # You can manipulate objects and associations before they are saved to the database, but there is some special behavior you should be # aware of, mostly involving the saving of associated objects. # - # Unless you set the :autosave option on a has_one, belongs_to, + # You can set the :autosave option on a has_one, belongs_to, # has_many, or has_and_belongs_to_many association. Setting it # to +true+ will _always_ save the members, whereas setting it to +false+ will # _never_ save the members. From c2341ee71ae0e5d3ec2873ad8e034d8a4e88ed54 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 21:43:29 -0400 Subject: [PATCH 15/20] superclass_delegating_accessor has been deprecated. I am working on removing all traces of superclass_delegating_accessor from rails code base. https://rails.lighthouseapp.com/projects/8994/tickets/2914-superclass_delegating_accessor-needs-to-be-deprecated-nicely --- .../source/active_support_core_extensions.textile | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index d14a531abe..6ee7a4220b 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1135,21 +1135,6 @@ Since values are copied when a subclass is defined, if the base class changes th NOTE: Defined in +active_support/core_ext/class/inheritable_attributes.rb+. -There's a related macro called +superclass_delegating_accessor+, however, that does not copy the value when the base class is subclassed. Instead, it delegates reading to the superclass as long as the attribute is not set via its own writer. For example, +ActionMailer::Base+ defines +delivery_method+ this way: - - -module ActionMailer - class Base - superclass_delegating_accessor :delivery_method - self.delivery_method = :smtp - end -end - - -If for whatever reason an application loads the definition of a mailer class and after that sets +ActionMailer::Base.delivery_method+, the mailer class will still see the new value. In addition, the mailer class is able to change the +delivery_method+ without affecting the value in the parent using its own inherited class attribute writer. - -NOTE: Defined in +active_support/core_ext/class/delegating_attributes.rb+. - h4. Subclasses & Descendants h5. +subclasses+ From 2df365529bf82c76512c6462b19bf196ad932c73 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 21:50:24 -0400 Subject: [PATCH 16/20] putting receive method under tt --- actionmailer/README.rdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index 64b0333c0a..b52c993f56 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -74,9 +74,9 @@ Or you can just chain the methods together like: == Receiving emails -To receive emails, you need to implement a public instance method called receive that takes a +To receive emails, you need to implement a public instance method called receive that takes a tmail object as its single parameter. The Action Mailer framework has a corresponding class method, -which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns +which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns into the tmail object and calls the receive instance method. Example: From daad4454eb4eeeb76749735490e1b355fcf9e827 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 22:22:50 -0400 Subject: [PATCH 17/20] itsy bitsy changes to ActionMailer documentation --- actionmailer/lib/action_mailer/base.rb | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 7bbde53306..1ac8f9da1d 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -41,16 +41,16 @@ module ActionMailer #:nodoc: # in the same manner as attachments[]= # # * headers[]= - Allows you to specify any header field in your email such - # as headers['X-No-Spam'] = 'True'. Note, while most fields (like To: + # as headers['X-No-Spam'] = 'True'. Note, while most fields like To: # From: can only appear once in an email header, other fields like X-Anything # can appear multiple times. If you want to change a field that can appear multiple times, - # you need to set it to nil first so that Mail knows you are replacing it, not adding - # another field of the same name.) + # you need to set it to nil first so that Mail knows you are replacing it and not adding + # another field of the same name. # # * headers(hash) - Allows you to specify multiple headers in your email such # as headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'}) # - # * mail - Allows you to specify your email to send. + # * mail - Allows you to specify email to be sent. # # The hash passed to the mail method allows you to specify any header that a Mail::Message # will accept (any valid Email header including optional fields). @@ -66,7 +66,7 @@ module ActionMailer #:nodoc: # format.html # end # - # The block syntax is useful if also need to specify information specific to a part: + # The block syntax is also useful in providing information specific to a part: # # mail(:to => user.email) do |format| # format.text(:content_transfer_encoding => "base64") @@ -121,7 +121,7 @@ module ActionMailer #:nodoc: # # <%= users_url(:host => "example.com") %> # - # You will want to avoid using the name_of_route_path form of named routes because it doesn't + # You want to avoid using the name_of_route_path form of named routes because it doesn't # make sense to generate relative URLs in email messages. # # It is also possible to set a default host that will be used in all mailers by setting the :host @@ -132,7 +132,7 @@ module ActionMailer #:nodoc: # Setting ActionMailer::Base.default_url_options directly is now deprecated, use the configuration # option mentioned above to set the default host. # - # If you do decide to set a default :host for your mailers you will want to use the + # If you do decide to set a default :host for your mailers you want to use the # :only_path => false option when using url_for. This will ensure that absolute URLs are # generated because the url_for view helper will, by default, generate relative URLs when a # :host option isn't explicitly provided. @@ -154,7 +154,7 @@ module ActionMailer #:nodoc: # detect and use multipart templates, where each template is named after the name of the action, followed # by the content type. Each such detected template will be added as separate part to the message. # - # For example, if the following templates existed: + # For example, if the following templates exist: # * signup_notification.text.plain.erb # * signup_notification.text.html.erb # * signup_notification.text.xml.builder @@ -171,8 +171,7 @@ module ActionMailer #:nodoc: # # = Attachments # - # You can see above how to make a multipart HTML / Text email, to send attachments is just - # as easy: + # Sending attachment in emails is easy: # # class ApplicationMailer < ActionMailer::Base # def welcome(recipient) @@ -189,10 +188,8 @@ module ActionMailer #:nodoc: # # = Inline Attachments # - # You can also specify that a file should be displayed inline with other HTML. For example a - # corporate logo or a photo or the like. - # - # To do this is simple, in the Mailer: + # You can also specify that a file should be displayed inline with other HTML. This is useful + # if you want to display a corporate logo or a photo. # # class ApplicationMailer < ActionMailer::Base # def welcome(recipient) From 627d870c92e59fb5c2205df0ef897a525c9e85bc Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 22:44:32 -0400 Subject: [PATCH 18/20] itsy bitsy changes to documentation --- .../core_ext/date/calculations.rb | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb index e6a213625c..c5b54318ce 100644 --- a/activesupport/lib/active_support/core_ext/date/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date/calculations.rb @@ -40,23 +40,23 @@ class Date end end - # Tells whether the Date object's date lies in the past + # Returns true if the Date object's date lies in the past. Otherwise returns false. def past? self < ::Date.current end - # Tells whether the Date object's date is today + # Returns true if the Date object's date is today. def today? self.to_date == ::Date.current # we need the to_date because of DateTime end - # Tells whether the Date object's date lies in the future + # Returns true if the Date object's date lies in the future. def future? self > ::Date.current end # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) - # and then subtracts the specified number of seconds + # and then subtracts the specified number of seconds. def ago(seconds) to_time_in_current_zone.since(-seconds) end @@ -127,22 +127,22 @@ class Date ) end - # Returns a new Date/DateTime representing the time a number of specified months ago + # Returns a new Date/DateTime representing the time a number of specified months ago. def months_ago(months) advance(:months => -months) end - # Returns a new Date/DateTime representing the time a number of specified months in the future + # Returns a new Date/DateTime representing the time a number of specified months in the future. def months_since(months) advance(:months => months) end - # Returns a new Date/DateTime representing the time a number of specified years ago + # Returns a new Date/DateTime representing the time a number of specified years ago. def years_ago(years) advance(:years => -years) end - # Returns a new Date/DateTime representing the time a number of specified years in the future + # Returns a new Date/DateTime representing the time a number of specified years in the future. def years_since(years) advance(:years => years) end @@ -152,22 +152,22 @@ class Date years_ago(1) end unless method_defined?(:prev_year) - # Short-hand for years_since(1) + # Shorthand for years_since(1) def next_year years_since(1) end unless method_defined?(:next_year) - # Short-hand for months_ago(1) + # Shorthand for months_ago(1) def prev_month months_ago(1) end unless method_defined?(:prev_month) - # Short-hand for months_since(1) + # Shorthand for months_since(1) def next_month months_since(1) end unless method_defined?(:next_month) - # Returns a new Date/DateTime representing the "start" of this week (i.e, Monday; DateTime objects will have time set to 0:00) + # Returns a new Date/DateTime representing the "start" of this week (i.e, Monday; DateTime objects will have time set to 0:00). def beginning_of_week days_to_monday = self.wday!=0 ? self.wday-1 : 6 result = self - days_to_monday @@ -176,7 +176,7 @@ class Date alias :monday :beginning_of_week alias :at_beginning_of_week :beginning_of_week - # Returns a new Date/DateTime representing the end of this week (Sunday, DateTime objects will have time set to 23:59:59) + # Returns a new Date/DateTime representing the end of this week (Sunday, DateTime objects will have time set to 23:59:59). def end_of_week days_to_sunday = self.wday!=0 ? 7-self.wday : 0 result = self + days_to_sunday.days From 1a6d76223bf6a022a5755e645742ac84788e6668 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Thu, 29 Jul 2010 09:18:29 -0400 Subject: [PATCH 19/20] expanding on the will_change! method in documentation --- activemodel/lib/active_model/dirty.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index 4c80863e3a..5ea7636427 100644 --- a/activemodel/lib/active_model/dirty.rb +++ b/activemodel/lib/active_model/dirty.rb @@ -83,7 +83,10 @@ module ActiveModel # person.name_changed? # => false # person.name # => 'Bill' # - # Before modifying an attribute in-place: + # If an attribute is modified in-place then make use of [attribute_name]_will_change! + # to mark that the attribute is changing. Otherwise ActiveModel can't track changes to + # in-place attributes. + # # person.name_will_change! # person.name << 'y' # person.name_change # => ['Bill', 'Billy'] From 873c5a9e5924a7776692b9a17b03d0becec6e513 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Thu, 29 Jul 2010 10:29:33 -0400 Subject: [PATCH 20/20] adding documentation regarding time_zone_aware_attributes and skip_time_zone_conversion_for_attributes --- activerecord/lib/active_record/base.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5898ec3732..99043af1a5 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -220,6 +220,19 @@ module ActiveRecord #:nodoc: # user = User.create(:preferences => %w( one two three )) # User.find(user.id).preferences # raises SerializationTypeMismatch # + # == Time Zone aware attributes + # + # By default, ActiveRecord::Base keeps all the datetime columns time zone aware by executing following code. + # + # ActiveRecord::Base.time_zone_aware_attributes = true + # + # This feature can easily be turned off by assigning value false . + # + # If your attributes are time zone aware and you desire to skip time zone conversion for certain attributes then you can do following: + # + # Topic.skip_time_zone_conversion_for_attributes = [:written_on] + # + # # == Single table inheritance # # Active Record allows inheritance by storing the name of the class in a column that by default is named "type" (can be changed