Skip to content Skip to sidebar Skip to footer

Adding New Styles To Stylesheet Not Working In Rails

I'm working on a ROR app. It has a style.css stylesheet in its public/scaffold_files folder. I can see the style reference to this file when I inspect the elements. But now I want

Solution 1:

The rails asset pipeline is broken up into 3 different sections.

  • app/assets is for assets that are owned by the application, usually scripted by yourself.

  • lib/assets is for your own libraries' code that doesn't really fit
    into the scope of the application or those libraries which are shared across applications.

  • vendor/assets is for assets that are 3rd party, such as js plugins and frameworks.

It is generally bad practise to start adding assets in the public folder. When your asset pipeline tries to compile and compress them in production, it won't be able to find them because it only looks in the app, lib and vendor folders.

To get started, just create a file called 'application.css' within the app/assets folder. Then reference this file within your layout (layout/application.html.erb) using the following syntax:

<%= stylesheet_link_tag :application %>

This will automatically look in the app/assets folder, and retrieve, the file named 'application'. Thereby rendering new styles within your applcation!

If you need further help with assets, check out the RailsGuides; they have alot of helpful and in depth content.

http://guides.rubyonrails.org/asset_pipeline.html


Post a Comment for "Adding New Styles To Stylesheet Not Working In Rails"