views:

157

answers:

1

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 (e.g. 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

+1  A: 

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
Tomas Markauskas
Where should I add the helper_method call? I'm pretty ruby/rails green..
Infinity
@Infinity: I've updated the answer.
Tomas Markauskas