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

  • Home
  • SEARCH
  • 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 7818977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:45:09+00:00 2026-06-02T06:45:09+00:00

I have a separate scss file for each controller and I don’t import them

  • 0

I have a separate scss file for each controller and I don’t import them all to the application.css file so that I can include controller specific stylesheet and js file in the layout.

So in the layout I do:

<%= stylesheet_link_tag "application" %>
<%= stylesheet_link_tag params[:controller], :media => "all" %>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag params[:controller] %>

But when I run rake assets:precompile I don’t get compiled assets for the controllers.

I looked for solutions on the web, but they all stated to add needed files to the config.assets.precompile staitment. And I don’t know what to put there so that all the assets in subfolders of app/assets/stylesheets and subfolders of app/assets/javascripts get compiled automaticaly.

UPDATE 1

OK, I will compile all them in one file, but there are two problems:

  1. I have a _base.scss file containing all the needed variables and imports, and have renames application.css to application.css.scss so that i can import that file before everything else:

    @import 'base';
    @import 'style';
    @import 'forms';
    

How do I need to do that with a manifest? Could not find a way to import the whole directory with scss itself.

  1. I have some different actions for same selectors in different controllers. What is the easyest way to separate those actions and define witch should be processed on a particular page?
  • 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-02T06:45:11+00:00Added an answer on June 2, 2026 at 6:45 am

    This is a bad idea because it adds extra HTTP requests for each page load, requires a lot of extra files (most of which will be empty, there’s rarely going to be actual controller-specific CSS/JS), and ignores browser caching (cache the application.css/js once and forget about it).

    Better to write your CSS/JS in such a way that you can include it all together and use the asset pipeline properly.

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

Sidebar

Related Questions

I have three separate applications A, B and C. All of them use service
How can I have separate click events for each column in listview ? I
In Apple iTunes app market one can have separate screenshots for each language -
I have separate php files. I have a master file that I use by
I have a DataGrid with 3 DataGridColumns. All 3 of them have separate dataFields.
i have separate xml file which has jdbc , mysql details. Now i don't
I have separate file with listener. I want to attach that listener to button,
Do I need to have separate/multiple workers to run multiple websites (each with a
What's the best way to have separate CSS for IE and other browsers? I'm
In my ASP.NET application I have separate projects for the Data, Business and UI

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.