Rails3.0を使用しています。ビューshow_javascript.jsにあるJavascriptファイルを追加したい。/public/javascripts/show.html.erb
show.html.erbファイルは<head>...</head>テンプレートから一部を取得しますapplication.html.erb
どのように追加すればよいか悩んでいます。
Rails3.0を使用しています。ビューshow_javascript.jsにあるJavascriptファイルを追加したい。/public/javascripts/show.html.erb
show.html.erbファイルは<head>...</head>テンプレートから一部を取得しますapplication.html.erb
どのように追加すればよいか悩んでいます。
一般的なスタイルシート レイアウトがあると仮定すると、以下を に追加できますapplication.html.erb。
<%= javascript_link_tag 'show' if params[:action] == 'show' %>
次のように、セクションでcontent_forparams plusを使用することもできます。yield<head>
layout.html.erb
<head>
<%= yield(:header) if @content_for_header %>
</head>
product/show.html.erb
<% content_for :header do -%>
<%= javascript_link_tag 'show_product' %>
<% end -%>