I want Rails to inject different js files in development and production modes.
Example:
Development:
<script src="/javascripts/jquery.js" type="text/javascript"></script>
<script src="/javascripts/myscripts.js" type="text/javascript"></script>
Production:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="/javascripts/myscripts.min.js" type="text/javascript"></script>
Is it possible to achieve it in Rails 3?
Regards,
Alexey Zakharov
You could have a helper method load your js and perform the condition check as to which environment it is.
app/views/layouts/application.html.* (wherever you normally include your javascript)
app/helpers/application_helper.rb
You could DRY it up a little further by having
load_javascriptonly give you back a list of the files and have only onejavascript_include_tag.