javascript code execution on all pages except one.

For all my applicatino I use layout A.
In this layout I have <%= javascript_include_tag 'application.js' %>
and, in this javascript I have some code that I want to execute on all
pages exept one.
How can I exclude this javascript only for one page?

You could extract that code to a separate .js file and have a separate
layout for that page that does not include the new js file.


But I have to duplicate the layout code only to not include a .js?
All the pages have the same layout.

Put all the common stuff in a separate file or files and yield to
it/them from the layouts.


You could stick <%= yield :extra_js %> in the head section of the
layout and then use content_for :extra_js with the include for the
extra javascript file


Yes that's a solution, thank you.

Can I use content_for in a partial too?

Are you asking because you tried it and it didn't work?

I don't see anything in the documentation that indicates it would NOT
work in a partial.

It should work in partials, but will not work if you are rendering the partial in an ajax call