lib/gon/helpers.rb in gon-0.2.1 vs lib/gon/helpers.rb in gon-0.2.2
- old
+ new
@@ -6,14 +6,14 @@
module InstanceMethods
def include_gon
data = Rails.cache.read('gon_variables') || {}
- script = "<script>function Gon(){"
+ script = "<script>window.Gon = {};"
data.each do |key, val|
- script += "this." + key.to_s + val.to_json + ";"
+ script += "Gon." + key.to_s + val.to_json + ";"
end
- script += "}; var Gon = new Gon()</script>"
+ script += "</script>"
script.html_safe
end
end
end