Snels Nick
Snels Nick

Reputation: 955

Rails 3 replaces & with & in text_field

I'm using Rails 3. When a user submits a form with a text_field and has & entered in it, the form gets validated. When it isn't valid, Rails returns an error, which I then show to the user. But now the & is translated to & . How can I change this behaviour? Thanks.

Upvotes: 6

Views: 2610

Answers (2)

boulder_ruby
boulder_ruby

Reputation: 39733

Maybe try "risky string".html_safe

Upvotes: 2

Snels Nick
Snels Nick

Reputation: 955

I found the culprit. I was sending my input to a sanitizer method, which replaced all ampersands by &.

Upvotes: 4

Related Questions