2011-09-06 1 views
4

... 내가 읽은 무엇을, 내 deploy.rb에 다음 코드를 넣었습니다 바탕으로 Rails 3.1 - 애셋이 프로덕션에서 사전 컴파일되고 있는지 어떻게 알 수 있습니까? 레일 3.1 응용 프로그램을 배포의 묘리를 터득하려고

:

before "deploy:symlink", "assets:precompile" 

namespace :assets do 
    desc "Compile assets" 
    task :precompile, :roles => :app do 
    run "cd #{release_path} && rake RAILS_ENV=#{rails_env} assets:precompile" 
    end 
end 

그러나에 진실을 말하면, 나는 그것의 유무에 상관없이 어떤 차이도 느낄 수 없다. 내가 여기서 누락 된 것이 있습니까?

http://spreecommerce.com/blog

당신이 일반적으로 (프로덕션 서버에) 다음 레이크 작업을 실행하는 것입니다 생산을 위해 자산을 사전 컴파일하려면 :

편집 *는 답을 발견했다.

$ bundle exec rake assets : 사전 컴파일 추가 캐싱의 이점을 위해 파일 이름에 MD5 지문을 포함시키면서 모든 자산을 public/assets 디렉토리에 씁니다.

참고 : 제작시 image_tag, asset_path, javascript_include_tag 등을 사용하는보기의 자산에 대한 모든 참조는 파일 이름에이 지문을 자동으로 포함하므로 올바른 버전이 제공됩니다.

답변

0

구성이 있지만 기본적으로 올바르게 설정되어야합니다. 당신의 설정/application.rb에 가서 당신이 찾을 수 있는지 :

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    # Bundler.require(:default, :assets, Rails.env) 
end 
... 
config.assets.enabled = true 

당신은 또한 당신의 production.rb 파일에있는 사람들이 있어야합니다

# Compress JavaScripts and CSS 
config.assets.compress = true 

# Don't fallback to assets pipeline if a precompiled asset is missed 
config.assets.compile = false 

이 그런 식으로 설정해야합니다. 그렇지?