From 22f5c6d86399e7a40e7232a14718d5eb23177081 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 27 Apr 2010 15:12:19 -0400 Subject: [PATCH 1/2] documentation fix for ActiveModle [#4489 state:resolved] --- activemodel/README | 2 +- activemodel/lib/active_model/errors.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/activemodel/README b/activemodel/README index 3945a6d..6b0806a 100644 --- a/activemodel/README +++ b/activemodel/README @@ -96,7 +96,7 @@ functionality from the following modules: errors.add(:name, "can not be nil") if name == nil end - def ErrorsPerson.human_attribute_name(attr, options = {}) + def self.human_attribute_name(attr, options = {}) "Name" end diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index e6c86c7..17c4373 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -33,11 +33,11 @@ module ActiveModel # send(attr) # end # - # def ErrorsPerson.human_attribute_name(attr, options = {}) + # def self.human_attribute_name(attr, options = {}) # attr # end # - # def ErrorsPerson.lookup_ancestors + # def self.lookup_ancestors # [self] # end # -- 1.6.5.2 From a02d33e2725febe6f8cbd28e57bbbbe0f65ead32 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 27 Apr 2010 21:55:24 -0400 Subject: [PATCH 2/2] json_escape makes json invalid doc change [#1485 state:resolved] --- .../core_ext/string/output_safety.rb | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index b53929c..270d03a 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -35,10 +35,16 @@ class ERB # A utility method for escaping HTML entities in JSON strings. # This method is also aliased as j. # + # Note that after this operation is performed the output is not + # a valid JSON. + # # In your ERb templates, use this method to escape any HTML entities: # <%=j @person.to_json %> # # ==== Example: + # puts json_escape("{\"name\":\"john\",\"created_at\":\"2010-04-28T01:39:31Z\",\"id\":1}") + # # => {name:john,created_at:2010-04-28T01:39:31Z,id:1} + # # puts json_escape("is a > 0 & a < 10?") # # => is a \u003E 0 \u0026 a \u003C 10? def json_escape(s) -- 1.6.5.2