From 84bd203b39b0905723fc8be38bc9fd24f618e252 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 25 Jan 2012 09:31:00 -0200 Subject: Change ActiveRecord::Errors to ActiveModel::Errors in guides Use ActiveModel::Errors in inflection example docs as well. Also fixes wrong information and link to locale file related to Errors#full_messages in I18n guide. --- activeresource/lib/active_resource/validations.rb | 2 +- .../lib/active_support/core_ext/string/inflections.rb | 4 ++-- activesupport/lib/active_support/inflector/methods.rb | 12 ++++++------ .../source/active_record_validations_callbacks.textile | 2 +- railties/guides/source/active_resource_basics.textile | 2 +- railties/guides/source/i18n.textile | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb index ca265d053e..a63f02cb57 100644 --- a/activeresource/lib/active_resource/validations.rb +++ b/activeresource/lib/active_resource/validations.rb @@ -41,7 +41,7 @@ module ActiveResource # Module to support validation and errors with Active Resource objects. The module overrides # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned # in the web service response. The module also adds an +errors+ collection that mimics the interface - # of the errors provided by ActiveRecord::Errors. + # of the errors provided by ActiveModel::Errors. # # ==== Example # diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index 1e57b586d9..2194dafe4d 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -100,8 +100,8 @@ class String # # +underscore+ will also change '::' to '/' to convert namespaces to paths. # - # "ActiveRecord".underscore # => "active_record" - # "ActiveRecord::Errors".underscore # => active_record/errors + # "ActiveModel".underscore # => "active_model" + # "ActiveModel::Errors".underscore # => "active_model/errors" def underscore ActiveSupport::Inflector.underscore(self) end diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 7f325aee94..c245b5b53c 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -42,10 +42,10 @@ module ActiveSupport # +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces. # # Examples: - # "active_record".camelize # => "ActiveRecord" - # "active_record".camelize(:lower) # => "activeRecord" - # "active_record/errors".camelize # => "ActiveRecord::Errors" - # "active_record/errors".camelize(:lower) # => "activeRecord::Errors" + # "active_model".camelize # => "ActiveModel" + # "active_model".camelize(:lower) # => "activeModel" + # "active_model/errors".camelize # => "ActiveModel::Errors" + # "active_model/errors".camelize(:lower) # => "activeModel::Errors" # # As a rule of thumb you can think of +camelize+ as the inverse of +underscore+, # though there are cases where that does not hold: @@ -66,8 +66,8 @@ module ActiveSupport # Changes '::' to '/' to convert namespaces to paths. # # Examples: - # "ActiveRecord".underscore # => "active_record" - # "ActiveRecord::Errors".underscore # => active_record/errors + # "ActiveModel".underscore # => "active_model" + # "ActiveModel::Errors".underscore # => "active_model/errors" # # As a rule of thumb you can think of +underscore+ as the inverse of +camelize+, # though there are cases where that does not hold: diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index ac5ee0694c..844876a973 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -671,7 +671,7 @@ h3. Working with Validation Errors In addition to the +valid?+ and +invalid?+ methods covered earlier, Rails provides a number of methods for working with the +errors+ collection and inquiring about the validity of objects. -The following is a list of the most commonly used methods. Please refer to the +ActiveRecord::Errors+ documentation for a list of all the available methods. +The following is a list of the most commonly used methods. Please refer to the +ActiveModel::Errors+ documentation for a list of all the available methods. h4(#working_with_validation_errors-errors). +errors+ diff --git a/railties/guides/source/active_resource_basics.textile b/railties/guides/source/active_resource_basics.textile index 851aac1a3f..37abb8a640 100644 --- a/railties/guides/source/active_resource_basics.textile +++ b/railties/guides/source/active_resource_basics.textile @@ -71,7 +71,7 @@ person.destroy h3. Validations -Module to support validation and errors with Active Resource objects. The module overrides Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned in the web service response. The module also adds an errors collection that mimics the interface of the errors provided by ActiveRecord::Errors. +Module to support validation and errors with Active Resource objects. The module overrides Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned in the web service response. The module also adds an errors collection that mimics the interface of the errors provided by ActiveModel::Errors. h4. Validating client side resources by overriding validation methods in base class diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 16ad35f345..25201888e7 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -819,13 +819,13 @@ h5. Action View Helper Methods * The +number_to_currency+, +number_with_precision+, +number_to_percentage+, +number_with_delimiter+, and +number_to_human_size+ helpers use the number format settings located in the "number":https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L2 scope. -h5. Active Record Methods +h5. Active Model Methods * +model_name.human+ and +human_attribute_name+ use translations for model names and attribute names if available in the "activerecord.models":https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml#L29 scope. They also support translations for inherited class names (e.g. for use with STI) as explained above in "Error message scopes". -* +ActiveRecord::Errors#generate_message+ (which is used by Active Record validations but may also be used manually) uses +model_name.human+ and +human_attribute_name+ (see above). It also translates the error message and supports translations for inherited class names as explained above in "Error message scopes". +* +ActiveModel::Errors#generate_message+ (which is used by Active Model validations but may also be used manually) uses +model_name.human+ and +human_attribute_name+ (see above). It also translates the error message and supports translations for inherited class names as explained above in "Error message scopes". -* +ActiveRecord::Errors#full_messages+ prepends the attribute name to the error message using a separator that will be looked up from "activerecord.errors.format.separator":https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L91 (and which defaults to +' '+). +* +ActiveModel::Errors#full_messages+ prepends the attribute name to the error message using a separator that will be looked up from "errors.format":https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml#L4 (and which defaults to +"%{attribute} %{message}"+). h5. Active Support Methods -- cgit v1.2.3