I come from a PHP and Python/GAE background and am new to RoR. Typically I'd have a global variable set up containing my unsecure and secure webpage's url, for use when templating. For example, if I want to link to an image, rather than saying img src="www.mysite.com/images/img1.png" I can use img src="{{ unsecure_url }}images/img1.png".
I'm thinking the best way to do this in RoR is to add the following to my application_helper. Is that valid?
def unsecure_url
"http://localhost:3000/"
end
def secure_url
"https://localhost:3000/"
end
And how can I switch between localhost and production, depending on whether I'm in a local environment or not?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.