I want to have a different set of stylesheets for the different parts of my Rails application. For example, I want to have a set of stylesheets for the landing page, a different set for the backend admin
pages, and another set for the logged in account
pages.
I've organized the stylesheets into folders with the names account, home, and admin, and I know how to specify in the application.css to just compile one folder.
*= require_self
*= require_tree ./account
*/
My question is, how do I specify that if the user is viewing the admin pages, or the home pages that the stylesheets in the admin or home folder should be the only style sheets that are referenced?
Thanks
There is no way to create conditonal stylesheet creation, because on production it is compiled on deployment.
You must create separate stylesheets, for example one would be default application.css:
/*
*= require_self
*= require some_stylesheet
*/
Then separate, admin.css
/*
*= require_self
*= require some_admin_stylesheet
*/
Then in production enviroment configuration extend line:
config.assets.precompile += ['application.css', 'admin.css']
Next, create separate layout/or create conditional inclusion of:
<%= stylesheet_link_tag "admin" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With