Tuesday, September 25, 2007

Helper: get_url(url)

Answer to making our relative URLs to absolute URLs through the application helper:


def get_url(url)
return "http://localhost:3000" + url
end


If URL were /model/file/1/a.jpg, then you'd get http://localhost:3000/model/file/1/a.jpg in return. When moving to a new webserver, we just need to edit the helper and change the base URL.

No comments: