2012-05-30 2 views
1

레일즈를 배우고 있으며 답변을 찾을 수없는 프로 렘이 있습니다. 나는 두 개의 CSS 파일 "print.css"와 "screen.css"를 "/ public/stylesheets"에 가지고있다.레일스 스타일 시트가로드되지 않습니다.

레이아웃에서 "application.html.erb"파일을로드하고 서버를 시작하면 파일이 로컬 웹 사이트에서 누락되었습니다. 여기

GET http://localhost:3000/assets/print.css 404 (Not Found) 

GET http://localhost:3000/assets/screen.css 404 (Not Found) 

는 "application.html.erb"의 코드입니다 :

<!DOCTYPE html> 
<html> 
<head> 
    <title><%= title %></title> 
    <%= csrf_meta_tag %> 
    <%= stylesheet_link_tag "screen", "print" %> 

</head> 
<body> 
    <%= yield %> 
</body> 
</html> 

또한 내가 내 "./config이

config.assets.compile = true

을 추가 한이 오류입니다 /environment/development.rb "및 도망

bundle exec rake assets:precompile RAILS_ENV=development

아무 소용이 없습니다.

알려 주시기 바랍니다.

답변

3

asset pipeline에서 읽으십시오. public/ 디렉토리에 스타일 시트 (또는 자바 스크립트/이미지)를 두는 것은 더 이상 흔하지 않습니다. 오히려, 그들은 app/assets/stylesheets/에 놓아야합니다. 여기서 그들은 사전 컴파일되어 포함될 수 있습니다.

<%= stylesheet_include_tag 'application' %> 
0

대신 app/assets/stylesheets에 입력해야합니다.

관련 문제