Rails: javascript conditional tag executed locally includes

I want to load jQuery on a regular basis from http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.jsa work / development environment, as long as I do not run locally, but my own local jquery.min.js, if it is running locally (for example 0.0.0.0:3000)

The reason I sometimes have to do development work without an internet connection is mainly when I'm on the subway.

I did a conditional template if RAILS_ENV == 'development'in the template, but I needed to change the template every time I needed to force the production mode to be set.

I use haml btw .. not that it really matters.

What is the best way to do this? Thanks

+3
source share
1 answer

Does the ActionController have a local_request method ? . You will probably have to declare it as helper_method in order to use it in your views:

class ApplicationController < ActionController::Base
    helper_method :local_request?
    ...
end
+2
source

Source: https://habr.com/ru/post/1733302/


All Articles