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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
timfischbach (Guest)
on 2007-02-07 13: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/
223:       def remote_function(options)
240:         url_options = options[:url]
241:         url_options = url_options.merge(:escape => false) if
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 =>


<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.