unknown wrote in post #1154022:
> Hi all,
>
> Sorry if this has already been discussed, but I haven't found any post
> matching what I'm looking for.  (If there is, please point me to it!)
>
> I'd like to include a javascript in the header section, but just for one
> view.  I went through the guides and I understand you can do something
> like
> this inside a particular view:
>
> <% content_for :head do %>
>   <script src="(path_to_)myJavascript.js"></script>
> <% end %>
>
> However, if I add myJavascript.js in app/assets/javascripts, it gets
> loaded
> for every single page.

By default a new Rails application will load all javascript/coffeescript 
files under the app/assets/javascripts directory and all subdirectories.

Look for the following line in your application.js manifest file:

//= require_tree .

That does what it sounds like it would. It loads all javascripts in the 
entire subtree. This might be fine for very simple application, or for 
getting started, but probably not what you want in a more complex 
application.

This is explained in further detail here:
http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/e7c9abc39e7ef647c0cb3745f199f1de%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to