3

So my application.js file is including jquery accordingly, and everything I've put directly into it.

However, one of my controllers - lets call it Books - has its own books.js file

I want the books.js file only to be present when viewing pages within the books controller.

It doesn't seem to be including it at all though - any ideas?

3 Answers 3

3

First you should look at http://railscasts.com/episodes/279-understanding-the-asset-pipeline

Second in app/assets/javascripts/application.js

does it contain something like

//= require_directory .

or

//= require_tree .
Sign up to request clarification or add additional context in comments.

Comments

0

try:

<%= javascript_include_tag params[:controller] %>

3 Comments

ps - the rails guide on the asset pipeline is an excellent read
Wouldn't that defeat the concept of it loading all js files in app/assets/javascripts on its own?
@tybro not sure what you mean?
0

"everything I've put directly into it." ...does that mean you put your own code into application.js? If so, you might want to read a tutorial on the asset pipeline.

But anyways, sounds like //= require_tree . is missing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.