Forum: Ruby on Rails Form won't accept ampersand

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.
Ae03102311939454d2b7f1ca3139fd97?d=identicon&s=25 Lindsay Boyd (Guest)
on 2007-02-06 15:13
Hi guys,

My start_form_tag generated form will not accept a text field containing
an ampersand.

For example, the text 'A & B' is trunacted to 'A' in the param hash.

I know ampersands have to be encoded in URLs, but I'm surprised my form
has a problem with this. I've tested this in Safari and Firefox.

Ae03102311939454d2b7f1ca3139fd97?d=identicon&s=25 Lindsay Boyd (Guest)
on 2007-02-06 16:55
It turns out start_form_tag isn't the issue...

I've traced the problem down to an observe_field. The value being sent
by the AJAX call is 'A ' - the '&B' isn't sent, as one would expect. So,
how can I escape the value to send the '&' as an '&'? I've tried
':method => post' but that doesn't help either.

Be76443ea33cd2c4fe8f43e7441fc7fe?d=identicon&s=25 AdamSebWolf (Guest)
on 2007-02-06 17:41
(Received via mailing list)
I know that the function h(string) strips a string and converts all
escape characters into their html-code equivalents.
h "A & B"
will return "A & B"
h "A < B"
returns "A &lt; B"

I hope this helps, it's one of the few things I know!

Sebastian Wolf

On Feb 6, 3:55 pm, Lindsay Boyd <>
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-02-06 17:45
(Received via mailing list)
Hi Lindsay,

Hi Lindsay,

Lindsay Boyd wrote:
> how can I escape the value to send the '&'
> as an '&amp;'?

The problem, in general terms, is about accepting non-text input from
It's dangerous.  Here's a link to get you started.

This topic is locked and can not be replied to.