In Rails 3.1, what is a neat way to include a javascript file for only some views and exclude it from others?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In the view you want the script,
An alternative to the above, I use a javascript_include_tag pointing to the js file for that script instead of using the tag so that I can keep all my javascript in one place.
In the layout for that view where you have your other javascript: