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 8861385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:28:54+00:00 2026-06-14T15:28:54+00:00

Possible Duplicate: Rails 3.1 asset pipeline: how to load controller-specific scripts? Upon creating a

  • 0

Possible Duplicate:
Rails 3.1 asset pipeline: how to load controller-specific scripts?

Upon creating a new controller and associated view, Rails produces some empty view-specific assets. Take the following command:

rails generate controller home index

This will generate home.css.scss and home.js.coffee. Being new to Rails, my initial thought was that these would be auto-configured to only render in their respective views. It turns out that this is not the case. Instead, the default is that all scripts are rendered in all views. Is this expected? What’s the best way to make these assets view-specific?

  • 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-06-14T15:28:55+00:00Added an answer on June 14, 2026 at 3:28 pm

    The basic setup is that (in production) a single js file is served (and a single CSS file). This is usually more efficient from a caching point of view, at the expense possibly of a slightly slower first page load.

    When this gets too much you can create additional manifest files (application.js being the default one) and load them separately. For example one of the apps I work on has a separate admin.js/css since that has so little overlap with the consumer facing portion. You could in theory treat each js/CSS file as a manifest file although you’d need to be calling javascript_include_tag on each page.

    If the underlying reason for your question is that you have behaviour you want to attach only on certain pages then either make your selectors/js specific enough that they can tolerate being loaded on all pages, or (I usually do this) add a controller or action specific class on the body and use that.

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

Sidebar

Related Questions

Possible Duplicate: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
Possible Duplicate: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
Possible Duplicate: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
Possible Duplicate: Rails - AJAX to for new/create action I have a timeline that
Possible Duplicate: Rails: How do I pass custom params to a controller method? I
Possible Duplicate: Access a view helper for a model in rails I know this
Possible Duplicate: How do I override rails naming conventions? When you generate new models
Possible Duplicate: Rails 2.3-style plugins and deprecation warnings running task in Heroku I am
Possible Duplicate: Ruby On Rails 3 and Webrick issue $ rails server /Users/Vineeth/.rvm/gems/ruby-1.9.3-p194/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require':
Possible Duplicate: Rails primary key and object id Very quick question. My server is

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.