KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
So I'm trying to use a Rails URL helper ( page_url ) to create URLs that contain special characters, including ampersands. Most cases work like you'd expect them to: (rdb:1) page_url('foo', :host => 'host') "http://host/pages/foo" (rdb:1) page_url('foo_%_bar', :host => 'host') "http://host/pages/foo_%25_bar" But for some odd reason, ampersands are not escaped: (rdb:1) page_url('foo_&_bar', :host => 'host') "http://host/pages/foo_&_bar" And if I pre-escape them, they get corrupted: (rdb:1) page_url('foo_%26_bar', :host => 'host') "http://host/pages/foo_%2526_bar" CGI::escape , on the other hand, escapes them fine: (rdb:1) CGI::escape('foo_&_bar') "foo_%26_bar" What's going on, and how do I work around this? (With something nicer than gsub('&', '%26') , that is.)
Tags (comma-separated)
Save Edits
Cancel