Separate CSS Folders for Separate Rails Controllers

Is there a way to have separate css folders for individual rail controllers? I have two topics that I would like to combine. One for my home controller when the user is not subscribed. And one for my control panel controller when the user is connected. Both of them have several css and javascript files.

I know how to do this with a single css file. Example: a home controller only reads home.css.

But I would really like the folder for the home controller, as I want to stay organized with several files.

Any help would be appreciated.

+1
source share
1 answer

, . , .

. application.js

//= require_tree .

application.css

*= require_tree .

application.html.erb

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

config/initializers/assets.rb

%w( controller_one controller_two controller_three ).each do |controller|
  Rails.application.config.assets.precompile += ["#{controller}.js", "#{controller}.css"]
end

** control_one, two .. .

. . "". css. home.css( ) :

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *
 *= require home/freelancer
 *= require home/bootstrap
 *= require home/font-awesome
 */

"freelancer" , . / freelancer.css

, , .

*= require home/.

.

+1

All Articles