Forum: Ruby on Rails remote_function double escapes string in options[:url]

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aba14ca6104ad863c47759bc1a2fbbbe?d=identicon&s=25 timfischbach (Guest)
on 2007-02-07 12:16
(Received via mailing list)
I don't know if this is a known issue:

When passed a string as url remote_function double escapes it.
Escaping is only disabled for hashes:

# File vendor/rails/actionpack/lib/action_view/helpers/
prototype_helper.rb
223:       def remote_function(options)
[...]
240:         url_options = options[:url]
241:         url_options = url_options.merge(:escape => false) if
url_options.is_a?(Hash)
242:         function << "'#{url_for(url_options)}'"

This breaks the query string in urls which are genereated via named
routes. Example:

link_to_remote 'User', :url => user_path(:id => user, :a => 1, :b =>
2)

becomes:

<a href="#" onclick="new Ajax.Request('/users/1?a=1&amp;amp;b=2' [...]

Hence the parameter b is turned into amp;b.

Using hash_for_ helpers circumvents the problem.
This topic is locked and can not be replied to.