현재 Heroku와 Compass를 사용하고 있습니다. Heoku 기술 자료에서이 configuration을 권장합니다. Heroku는 읽기 전용 파일 시스템을 가지고 있으므로 컴파일 된 스타일 시트는/tmp에 저장해야합니다. 이것은 Heroku에서 원격으로 잘 작동합니다. 그러나 로컬에서는/public/stylesheets (= stylesheet_link_tag 'screen.css', :media => 'screen, projection'
을 통해 호출 할 때)에서 스타일 시트를 찾을 수 있습니다.Heroku에서 나침반 사용 :/tmp에서 스타일 시트를 원격 및 로컬로 사용합니다.
이 문제를 해결하기 위해 나는/public/stylesheets에서 심볼릭 링크를 ln -s tmp/stylesheets/screen.css public/stylesheets/screen.css
을 사용하여 만들었으며 제대로 작동하는 것으로 보인다.
레일스의 일부 구성을 변경하여 심볼 링크를 사용하지 않고도이 문제를 해결할 수 있습니까? 나는 많은 성공없이 찌르다. 여기
require 'compass'
require 'compass/app_integration/rails'
Compass::AppIntegration::Rails.initialize!
# Required for Heroku:
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets"))
Compass::AppIntegration::Rails.initialize!
Rails.configuration.middleware.delete('Sass::Plugin::Rack')
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Sass::Plugin::Rack')
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Rack::Static',
:urls => ['/stylesheets'],
:root => "#{Rails.root}/tmp")
그리고 내 설정/compass.rb입니다 : 어떤 도움을 크게 감상 할 수
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
# Set this to the root of your project when deployed:
http_path = "/"
# Necessary for Heroku (original commented out:
css_dir = 'tmp/stylesheets'
#css_dir = "public/stylesheets/compiled"
sass_dir = 'app/views/stylesheets'
environment = Compass::AppIntegration::Rails.env
여기
내 설정/초기화/compass.rb입니다.
이 기능은 레일즈 3에서 작동합니까? – anka
예 - 저는 Rails 3.0.5입니다. – jdc
이 솔루션에서 이해할 수없는 한 가지는 환경을 기반으로 "sass_dir"을 변경하는 이유입니다. 소스 파일이 저장된 곳이 아닌가요? dev/prok/heroku에서 dev에 비해 왜 다른가? 또한 Compass :: AppIntegration :: Rails.initialize를 호출하고 있습니다. 두번. –