Hi guys,
I want to set up my RoR project to use local javascript library for development and externally hosted for production (for example jquery from google). How it could be achieved?
Regards, Alexey Zakharov
Hi guys,
I want to set up my RoR project to use local javascript library for development and externally hosted for production (for example jquery from google). How it could be achieved?
Regards, Alexey Zakharov
<% if RAILS_ENV=“production”>
javascript_include_tag “http://somewhere.com/javascript_file_without_js”
<% else %>
javascript_include_tag “javascript_file_without_js”
<% end %>
http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#M002225
Best regards
Peter De Berdt
Typo: <% if RAILS_ENV=="production">
As an aside, the RAILS_ENV constant is now deprecated; the new way to do this test is:
if Rails.env.production?
Chris
Another option is to create your own configuration file and use the URL to the JavaScript file as a configuration variable.
See here: #85 YAML Configuration File - RailsCasts
Thanks guys. That was really helpful!