Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:45:42+00:00 2026-05-27T21:45:42+00:00

I think the docs http://guides.rubyonrails.org/asset_pipeline.html need some clarification. They state: For example, if a

  • 0

I think the docs http://guides.rubyonrails.org/asset_pipeline.html need some clarification. They state:

For example, if a ProjectsController is generated, there will be a new
file at app/assets/javascripts/projects.js.coffee and another at
app/assets/stylesheets/projects.css.scss. You should put any
JavaScript or CSS unique to a controller inside their respective asset
files, as these files can then be loaded just for these controllers
with lines such as <%= javascript_include_tag params[:controller] %>
or <%= stylesheet_link_tag params[:controller] %>.

It is my understanding that in production mode, all JS gets packaged up into one optimized file, preferably. I’m guessing that caching of this optimized file is preferable to having pages specifically loading different sets of JS files themselves.

Maybe the point of the javascript_include_tag is to RUN some specific javascript to that page. However, the default for application.js is to include the tree, which includes the generated files. So I’m guessing that would have to be adjusted to NOT include any controller specific javascript.

This answer here Using Rails 3.1, where do you put your "page specific" javascript code? seems to suggest a reasonable way of handling the issue is to associate JS features with divs, and when JQuery does not see the div on the page, nothing is executed.

So what is the best practice? Is my understanding of the controller specific divs correct? Does the default to include the tree inside of application.js conflict with the goals of controller specific js?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:45:43+00:00Added an answer on May 27, 2026 at 9:45 pm

    You shouldn’t rely on the application.js scaffold in my opinion. application.js requires the whole tree, but this is done to make it easy to start a project, it doesn’t mean it’s supposed to stay this way.

    It’s likely that you will create different “bundles” of files, some of them will just be included in specific pages.
    For instance, my application.js just requires librairies and every files in an application folder. This way you can still have page specific js.

    I guess that <%= javascript_include_tag params[:controller] %> can be useful if you have big javascript files specific to some controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

JSR-299 (CDI) introduces the (unfortunately named) concept of a resource: http://docs.jboss.org/weld/reference/1.0.0/en-US/html/resources.html#d0e4373 You can think
I went through the Hibernate Tutorial at http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html and got the question which fetch
In Python weakref document( http://docs.python.org/library/weakref.html ), it says that Several built-in types such as
I'm playing around with 2 objects {@link http://docs.python.org/library/datetime.html#datetime.date } I would like to calculate
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup I can think of a few ways of doing it with loops but
According to this: http://code.google.com/appengine/docs/whatisgoogleappengine.html it seems that GAE only uses Datastore to store data,
I'm using exactly the code in the examples from here: http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html#Auth Still no dice.
reading the docs here:http://grails.org/plugin/jquery-ui it says to use a custom theme I should put
I recently followed this tutorial on Google Cloud SQL and GWT: http://code.google.com/apis/sql/docs/developers_guide_java.html I deployed
I'm trying to use the jqueryui dialog ( http://docs.jquery.com/UI/Dialog ) within my html page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.