content-for

Including inline javascript using content_for in rails

拟墨画扇 提交于 2019-11-28 16:50:37
问题 I am using content_for and yeild to inject javascript files into the bottom of my layout but am wondering what the best practice is for including inline javascript. Specifically I'm wondering where the put the script type declaration: <% content_for :javascript do %> <script type="text/javascript"> ... </script> <% end %> or <% content_for :javascript do %> ... <% end %> <script type="text/javascript"> <%= yield :javascript %> </script> <% end %> I am using the first option now and wondering

how to render partial on everything except a certain action

走远了吗. 提交于 2019-11-28 16:43:23
I have a _header.html.erb partial which is where I put my navbar on my launch page I don't want to display the navbar. this is the body of application.html.erb <body> <%= render 'layouts/header' %> <div id="container"> <%= yield %> </div> </body> How do I render it on every action except specific actions on specific controllers? Replace your render with this: <%= render 'layouts/header' unless @disable_nav %> Then you can simply set disable_nav to true in any controller action you like: def landing_page @disable_nav = true end As a before_filter , which I'd encourage over the above: