Well, you can include the jQuery file at the top.
If this is not an option, add <%= yield :javascript %>jQuery to the layout below and run:
<% content_for :javascript do %>
<script type="text/javascript">
</script>
<% end %>
It will be placed in the right place in your layout. (However, I would recommend, for caching, that you write Javascript in an external file and include it where necessary, instead of using the built-in Javascript. Just good practice.)
source
share