Skip to content

Commit

Permalink
Only call url_for if :url is a hash. Calling url_for on a string esca…
Browse files Browse the repository at this point in the history
…pes ampersands in the querystring.
  • Loading branch information
copyhacker committed Dec 15, 2008
1 parent d367aac commit 6b1d552
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/jrails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ def options_for_ajax(options)
js_options = build_callbacks(options)

url_options = options[:url]
url_options = url_options.merge(:escape => false) if url_options.is_a?(Hash)
js_options['url'] = "'#{url_for(url_options)}'"

if url_options.is_a?(Hash)
url_options = url_options.merge(:escape => false)
js_options['url'] = "'#{url_for(url_options)}'"
else
js_options['url'] = "'#{url_options}'"
end

js_options['async'] = false if options[:type] == :synchronous
js_options['type'] = options[:method] ? method_option_to_s(options[:method]) : ( options[:form] ? "'post'" : nil )
js_options['dataType'] = options[:datatype] ? "'#{options[:datatype]}'" : (options[:update] ? nil : "'script'")
Expand Down

0 comments on commit 6b1d552

Please sign in to comment.