When using url_for to send path to a script (such as with auto_complete), multiple params are joined with the "&" code. For example: text_field_with_auto_complete :blog :post, {}, { :posts_path(:a => 1, :b => 2), :method => :get } Produces this script: var blog_post_auto_completer = new Ajax.Autocompleter(''blog_post'', ''blog_post_auto_complete'', ''/posts.js?a=1&b=2'', {method:''get''}) Notice that "&" in the path. When sent to the server, it get parsed as "a=1" and "amp;b=2". I think the script is correct because XHTML & to be coded as "&". Is this a bug in Mongrel? Has anyone else dealt with this? Gavin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 17 Jul 2008, at 11:09, Gavin wrote:> > When using url_for to send path to a script (such as with > auto_complete), multiple params are joined with the "&" code. For > example: > > text_field_with_auto_complete :blog :post, {}, { :posts_path(:a => > 1, :b => 2), :method => :get } > > Produces this script: > > var blog_post_auto_completer = new Ajax.Autocompleter(''blog_post'', > ''blog_post_auto_complete'', ''/posts.js?a=1&b=2'', {method:''get''}) > > Notice that "&" in the path. When sent to the server, it get > parsed as "a=1" and "amp;b=2". > > I think the script is correct because XHTML & to be coded as "&". > Is this a bug in Mongrel? Has anyone else dealt with this? >Not mongrel''s fault. It doesn''t know anything about & being encoded as & (that''s just a detail of html/xml etc..., whereas mongrel just cares about http) If anything it''s probably the fault of text_field_with_auto_complete since if you''re inside a cdata thing (like most javascript is) then you don''t need to escape the & Fred>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> If anything it''s probably the fault of text_field_with_auto_complete > since if you''re inside a cdata thing (like most javascript is) then > you don''t need to escape the &Indeed it''s quite likely you''re double-escaping the ampersand. Closely inspect the rendered HTML source to verify. -- Roderick van Domburg http://www.nedforce.nl -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I can''t reproduce this bug outside the plugin, so it does seem to be a problem with auto_complete. It''s strange because the generated path looks fine: Ajax.Autocompleter(''blog_post'', ''blog_post_auto_complete'', ''/posts.js? a=1&b=2'', {method:''get''}) This just gets sent to the index action, so that & is getting gummed up somewhere between submit and the start of the action. But where? This is a one-line hack to fix, but I''d rather see it working correctly. Gavin On Jul 17, 3:58 am, Roderick van Domburg <rails-mailing-l...@andreas- s.net> wrote:> Frederick Cheung wrote: > > If anything it''s probably the fault of text_field_with_auto_complete > > since if you''re inside a cdata thing (like most javascript is) then > > you don''t need to escape the & > > Indeed it''s quite likely you''re double-escaping the ampersand. Closely > inspect the rendered HTML source to verify. > > -- > Roderick van Domburghttp://www.nedforce.nl > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Has anyone found a fix for this or can you explain a little more in detail about your work around. how do you get your second value in the controller? when i try params[:amp;b] i get an error (as expected). i''ve messed around with this, but can''t quite seem to get anywhere, your help would be extremely appreciated On Jul 17, 10:42 am, Gavin <gav...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I can''t reproduce this bug outside the plugin, so it does seem to be a > problem with auto_complete. It''s strange because the generated path > looks fine: > > Ajax.Autocompleter(''blog_post'', ''blog_post_auto_complete'', ''/posts.js? > a=1&b=2'', {method:''get''}) > > This just gets sent to the index action, so that & is getting > gummed up somewhere between submit and the start of the action. But > where? This is a one-line hack to fix, but I''d rather see it working > correctly. > > Gavin > > On Jul 17, 3:58 am, Roderick van Domburg <rails-mailing-l...@andreas- > > s.net> wrote: > > Frederick Cheung wrote: > > > If anything it''s probably the fault of text_field_with_auto_complete > > > since if you''re inside a cdata thing (like most javascript is) then > > > you don''t need to escape the & > > > Indeed it''s quite likely you''re double-escaping the ampersand. Closely > > inspect the rendered HTML source to verify. > > > -- > > Roderick van Domburghttp://www.nedforce.nl > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---