Almost 1 hour of digging before i gave up and built this…
(Does not support https yet)
# /abs -> http://myx.com/abs
def path_to_url(path)
"http://#{request.host_with_port_without_standard_port_handling}/#{path.sub(%r[^/],'')}"
end
My Pragmatig life
Building web applications and fighting the daily madness
Almost 1 hour of digging before i gave up and built this…
(Does not support https yet)
# /abs -> http://myx.com/abs
def path_to_url(path)
"http://#{request.host_with_port_without_standard_port_handling}/#{path.sub(%r[^/],'')}"
end
2 comments
Comments feed for this article
November 24, 2008 at 18:48
Luis Lavena
Hmn,
url_for for full path didn’t do the job?
http://apidock.com/rails/ActionController/Base/url_for
November 24, 2008 at 19:01
pragmatig
nope, not enough when you got /xy/something (for example an image) and want to generate the url for it
url_for(’/path’) only generates ‘/path’ kind of disappointing