hagimotk-8XaeY8amjOr4cnfMI1FaMPZ8FUJU4vz8@public.gmane.org
2014-Aug-01 18:15 UTC
Where do I place the javascript file that is only required for one (or just a few) view(s)?
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. Years ago, when I did RoR development (before assets), I used to put javascripts in the public/javascripts. Is that still where I should put theses one-off javascript files? What is the best practice now? Thanks for any pointers! Kumi -- 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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/649f0a4a-5b17-440c-965d-57fa0c9961ae%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.