2012-07-03 4 views
0

heroku에 3.2 레일 앱이 있습니다. 나는 javascript가 프로덕션 모드에서로드되지 않는다는 사실을 해결하기 위해 찾을 수있는 모든 것을 시도했다. dev에 잘 작동합니다. 또한 heroku에 배포 할 때 프리 컴파일이 실패합니다. 그러나 prod에서 소스 코드를 보면 javascripts 파일 (/assets/application-32fdbd115c5d59c7be2876c103063600.js)이로드되고 내용이 있음을 분명히 알 수 있습니다.프로덕션 환경에서 자산 파이프 라인이 작동하지 않습니다. 시도했습니다.

나는 생각하고 읽을 수있는 모든 설정을 시도했다. 나는 무엇을해야할지 잘 모릅니다. 여기 내 설치가 production.rb 현재의 :

config.cache_classes = true 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 
    config.serve_static_assets = false 
    config.assets.compress = false 
    config.assets.compile = true 
    config.assets.digest = true 

    config.i18n.fallbacks = true 
    config.active_support.deprecation = :notify 

와 environment.rb에의

:

# Load the rails application 
require File.expand_path('../application', __FILE__) 

# Initialize the rails application 
App::Application.initialize! 

application.rb :

require File.expand_path('../boot', __FILE__) 

require "rails/all" 

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 

module App 
    class Application < Rails::Application 
config.encoding = "utf-8" 

    # Configure sensitive parameters which will be filtered from the log file. 
    config.filter_parameters += [:password] 

    # Enable escaping HTML in JSON. 
    config.active_support.escape_html_entities_in_json = true 
config.active_record.whitelist_attributes = true 

    # Enable the asset pipeline 
    config.assets.enabled = true 

    # Version of your assets, change this if you want to expire all your assets 
    config.assets.version = '1.0' 

내 gemfile :

gem 'rails', '3.2.6' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

gem 'pg' 
gem 'mysql2' 
gem 'thin' 
gem 'activerecord-postgresql-adapter' 
gem 'devise' 
gem 'paperclip', '~> 3.0' 
gem 'haml' 
gem 'activeadmin' 
gem "meta_search", '>= 1.1.0.pre' 
gem 'aws-sdk', '~> 1.3.4' 
gem 'acts_as_list' 
gem 'stripe' 
gem 'sass-rails', '~> 3.2.3' 


# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'coffee-rails', '~> 3.2.1' 
    gem 'twitter-bootstrap-rails' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer', :platforms => :ruby 

    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

group :development do 
    gem 'debugger' 
end 

아무 것도 작동하지 않는 것 같습니다. 내 로컬 컴퓨터 또는 heroku에서 생산 모드로. 그러나, 그것은 개발에 잘 작동합니다. 생산 상자에서

+0

Heroku를 다시 시작해 보셨습니까? 'heroku restart' –

+0

그래, 그게 아무것도 안했어 –

답변

2

. 기본적으로 문제는 .js 파일을 application.js로 압축하면 문제가 발생한다는 것입니다. production.rb에서 나는 이것을 넣었습니다 :

config.serve_static_assets = false 

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

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

    # Generate digests for assets URLs 
    config.assets.digest = true 

    config.assets.debug = true 

이 문제가 해결되었습니다. 그러나 이제는 application.js 대신 모든 자산 파일을 나열합니다. 장기간에 걸친 문제가 있는지 확실하지 않습니다.

1

는 당신이 시도 : 나는 마침내 내가이 수정 프로그램이 얼마나 잘 모르겠지만,이 문제를 해결하는 방법을 알아 냈 RAILS_ENV rake assets:precompile

+0

예, 몇 가지 다른 시간과 길을 시도했지만 ... 행운이 없음 –

+0

어떤 종류의 오류 메시지가 나타나거나 자산을 제공하지 못했습니까? – thisfeller

+0

오류 메시지가 표시되지 않지만 자산을로드하려고 할 때 내 로컬 컴퓨터에서 응답 402가 표시됩니다. 이상하게 보입니다. 자바 스크립트가 소스의 application.js 파일로 압축 된 것을 볼 수 있기 때문입니다. heroku에서 나는 프리 컴파일이 실패했다는 에러를 얻는다. 다시 말하지만 .js 파일에서 애셋을 볼 수 있습니다. 매우 이상한 –

관련 문제