2016-06-02 1 views
0

내가 그럼 난이 질문에레일 특정 erb보기에서 scss 파일을 포함하는 방법은 무엇입니까?

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

을 확인했습니다 view/work/index.html.erb

에서 assets/stylesheets/work.scss 파일을 포함하고 layout/application.html.erb

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

이를 추가 할, index.html.erb

이 추가
<% content_for :header do -%> 
<%= stylesheet_link_tag 'work' %> 
<% end -%> 
내가 precompile 필요한 이유

그러나이 오류 enter image description here

내가 대신 productiondevelopment 모드에서이 일을했다 던졌다?

답변

0

귀하는이를 독립적으로 포함하고 있으므로 귀하의 application.css에 포함시키지 않으 셨습니다. 자산 파이프 라인의 기본값은 applicaiton.css/application.js 및이 파일에 포함 된 모든 항목을 컴파일하는 것입니다.

/* 
* 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 
*/ 

당신이 별도의와 하나 개의 모 놀리 식 파일로 컴파일되지 싶은 경우

, 당신의 stylesheet_link_tag에서 호출되는 수동 프리 D 배열에 추가해야합니다.

http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets은 좋은 참고 자료입니다.

+0

감사합니다. 확인하겠습니다. –

+0

예, 자산 파이프 라인을 추가하면 제대로 작동 할 수 있습니다. 감사. –

관련 문제