0

I want to include the assets/stylesheets/work.scss file in view/work/index.html.erb

I've check this question

How to include a css or javascript in an erb that is outside the layout?

and add this in layout/application.html.erb

<head>
...
<%= yield(:header) if content_for? :header%>
</head>

Then, add this in index.html.erb

<% content_for :header do -%>
<%= stylesheet_link_tag 'work' %>
<% end -%>

However, it threw this error enter image description here

I was doing this in development mode instead of production, why I need precompile?

Community
  • 1
  • 1
rj487
  • 4,476
  • 6
  • 47
  • 88

1 Answers1

0

Because you are including it independently, and not including it in your application.css. The default for the asset pipeline is to compile applicaiton.css/application.js and anything that is included in those files.

/*
 * 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 any plugin's vendor/assets/stylesheets directory 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_tree .
 *= require c3
 *= require purecss
 *= require_self
 *= require pure_css_reset
 */

If you want it to be seperate and not compiled into the one monolithic file, being called from your stylesheet_link_tag, you have to manually add it to the precompile array.

http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets is a good reference.

Ropeney
  • 1,065
  • 8
  • 10