1
我在我的Ruby on Rails應用程序的輔助的unsecure_url獲取Ruby on Rails應用程序的URL?
def unsecure_url
"http://localhost:3000/"
end
然而,當應用程序是活的,這是錯誤的。我只是把應用程序在線,並想要做這樣的事情:
def unsecure_url
if is_production
production_url # <-- any way to determine this dynamically?
else
"http://localhost:3000/"
end
end
有關如何做到這一點的任何意見?
非常接近。我發現request.request_uri在RoR 3中被折舊 - 改爲使用request.fullpath。 – Geoff