I want to include this, for example:
jQuery(document).ready(function($) {
$(\'#my-modal\').modal(options)
});
In one specific place in
Given the JS file you want to include is named my_modal.js
:
Place your JS
files placed in assets/javascripts
in some directory inside of
assets/javascripts
, for example application
.
Change line //= require_tree .
to //= require_tree application
in your application.js
(it prevents loading my_modal.js
on every page).
Place your my_modal.js
in assets/javasctripts
Add my_modal.js
to config.assets.precompile
array (config assets.precompile += ['my_modal.js']
) in your application.rb
.
Put javascript_include_tag 'my_modal'
in the view you want this file included
You can go to Rails guides for reference.