One recommended practice is to load jQuery at the end of application layout:
= yield
= render 'shared/footer'
= javascript_include_tag 'jquery'
so that page rendering is faster without the hinderance of Javascript or jQuery. But what if there are some particular things that each view needs to do? For example, the index view need to do something, and the show view needs to do something else, and so the Javascript code would either be inside those view templates or be included from those view templates, but at this point, the jquery.js file is not loaded yet (not until near the end of page)? The jquery.js can be loaded before the yield, but then it is way in front of the page.
Your could use the content_for
In layout
In views
http://guides.rubyonrails.org/layouts_and_rendering.html#using-content_for