Register now and start sharing your code snippets.
-->
Allowing URL's in a route.
Ruby posted 3 months ago by marko
I wanted to create a route that could accept an URL as a parameter. The problem was that dots and slashes were interpreted as separators for the route. Luckily I managed to find this post that explained how it could be bypassed.
1 map.connect ':scale/:text.:format', :controller => 'barcode', :requirements => { :text => /.*/ }
With this route set up I now could catch parameters like this: http://localhost:3000/200×200/http://aktagon.com.png, where 200×200 is :scale, http://aktagon.com is :text and .png is :format.
Tagged rails routes, url in route