File tree Expand file tree Collapse file tree
railties/lib/rails/generators/rails/app/templates/config/initializers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11*Edge*
22
3+ * Changed the default ActiveSupport.use_standard_json_time_format from false to true and
4+ ActiveSupport.escape_html_entities_in_json from true to false to match previously announced Rails 3 defaults [DHH]
5+
36* Added Object#presence that returns the object if it's #present? otherwise returns nil [DHH/Colin Kelley]
47
58* Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH]
Original file line number Diff line number Diff line change @@ -114,7 +114,8 @@ def escape(string)
114114 end
115115 end
116116
117- self . escape_html_entities_in_json = true
117+ self . use_standard_json_time_format = true
118+ self . escape_html_entities_in_json = false
118119 end
119120
120121 CircularReferenceError = Deprecation ::DeprecatedConstantProxy . new ( 'ActiveSupport::JSON::CircularReferenceError' , Encoding ::CircularReferenceError )
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ module ActiveSupport
3232 # t.is_a?(Time) # => true
3333 # t.is_a?(ActiveSupport::TimeWithZone) # => true
3434 class TimeWithZone
35-
3635 def self . name
3736 'Time' # Report class name as 'Time' to thwart type checking
3837 end
@@ -114,9 +113,9 @@ def xmlschema(fraction_digits = 0)
114113 end
115114 alias_method :iso8601 , :xmlschema
116115
117- # Coerces the date to a string for JSON encoding.
118- #
119- # ISO 8601 format is used if ActiveSupport::JSON::Encoding.use_standard_json_time_format is set .
116+ # Coerces the date to a string for JSON encoding. The default format is ISO 8601. You can get
117+ # %Y/%m/%d %H:%M:%S +offset style by setting ActiveSupport::JSON::Encoding.use_standard_json_time_format
118+ # to false .
120119 #
121120 # ==== Examples
122121 #
Original file line number Diff line number Diff line change 44# for Rails 3. You can remove this initializer when Rails 3 is released.
55
66if defined? ( ActiveRecord )
7- # Include Active Record class name as root for JSON serialized output.
8- ActiveRecord ::Base . include_root_in_json = true
9-
107 # Store the full class name (including module namespace) in STI type column.
118 ActiveRecord ::Base . store_full_sti_class = true
12- end
13-
14- # Use ISO 8601 format for JSON serialized times and dates.
15- ActiveSupport . use_standard_json_time_format = true
16-
17- # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
18- # if you're including raw json in an HTML page.
19- ActiveSupport . escape_html_entities_in_json = false
9+ end
You can’t perform that action at this time.
0 commit comments