use ActiveSupport::JSON.encode instead of the to_json method (not reliable)

This commit is contained in:
did 2011-07-14 00:08:43 +02:00
parent 8956145da7
commit 2c562038d8
1 changed files with 1 additions and 1 deletions

View File

@ -46,7 +46,7 @@ module Admin::BaseHelper
def collection_to_js(collection, options = {})
js = collection.collect { |object| object.to_json }
options_to_js = options.to_json.gsub(/^\{/, '').gsub(/\}$/, '')
options_to_js = ActiveSupport::JSON.encode(options).gsub(/^\{/, '').gsub(/\}$/, '')
"new Object({ \"collection\": [#{js.join(', ')}], #{options_to_js} })"
end