@changelog: thx a lot for your answer.
The problem depicted below the line was solved by enclosing the <%= yield :myjs %>
in the appropriate javascript tags as follows:
<script type="text/javascript">
<%= yield :myjs %>
</script>
Thanks again!!
I tried to implement it the way you said, but I'm having some difficulties:
I put the following content_for block at the top of my show.html.erb:
<% content_for :myjs do %>
jQuery(document).ready(function($) { alert('hello'); });
<% end %>
In my layout.html I include all javascript as follows (here applications.js implements some general jQuery functions):
<head>
...
<%= javascript_include_tag 'jquery', 'application' %>
<%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
<% yield :myjs %>
</head>
<body>
...
The problem is that my javascript doesn't show up in the page's source when I call it. Also the alert function is not called.
When I put in <%= yield :myjs %>
instead (with the =) the javascript is rendered at the beginning of my body block, instead of the head, but still the alert function isn't called when I open the page.