I want to load jQuery from http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js
regularly, in production/development environment, as long as I'm not running locally, but my own local jquery.min.js
if running locally (eg 0.0.0.0:3000
)
Reason why is that I have to do some development without internet connection sometimes, mostly when riding the subway.
I've been doing a if RAILS_ENV == 'development'
conditional in the template, but it's annoying to have to change the template every time I need to force 'production' mode locally.
I'm using haml btw.. not that it really matters.
What's the best way to do this? Thanks
ActionController has a method local_request? . You will probably have to declare it as a helper_method to be able to use it in your views:
class ApplicationController < ActionController::Base
helper_method :local_request?
...
end
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.