2017-04-17 64 views
0

我的樣式表在heroku上停止加載(僅限生產模式,本地一切正常)。Rails樣式表未在heroku上加載(生產模式)

這裏是在Heroku上的錯誤信息記錄

ActionController::RoutingError (No route matches [GET] "/assets/application-cdff05ced6e18e533fc2f71d065b63f48ce16d3045406917ed854476a7eb1702.css") 

而事實上,當我運行

heroku rake assets:precompile 

其他文件被預編譯

/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:458: warning: already initialized constant Readline::HISTORY 
/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:486: warning: already initialized constant Readline::FILENAME_COMPLETION_PROC 
/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:517: warning: already initialized constant Readline::USERNAME_COMPLETION_PROC 
/app/vendor/bundle/ruby/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:523: warning: already initialized constant Readline::VERSION 
I, [2017-04-17T09:41:44.957818 #4] INFO -- : Writing /app/public/assets/application-f295a8fe23711032f76515a85070c9a4a7195e35bb2ea56572a87cab10734aef.js 
I, [2017-04-17T09:41:44.958361 #4] INFO -- : Writing /app/public/assets/application-f295a8fe23711032f76515a85070c9a4a7195e35bb2ea56572a87cab10734aef.js.gz 
I, [2017-04-17T09:41:50.103993 #4] INFO -- : Writing /app/public/assets/application-e86e4356a42c5e1f39646b26c890239ee4734ecd3a9a5e4214aea2a68d0e4509.css 
I, [2017-04-17T09:41:50.104211 #4] INFO -- : Writing /app/public/assets/application-e86e4356a42c5e1f39646b26c890239ee4734ecd3a9a5e4214aea2a68d0e4509.css.gz 

有關於這個主題的許多職位,現在,這是我的幾個不成功的其他嘗試後,我的production.rb文件。

config.serve_static_files = true 
config.assets.initialize_on_precompile = false 
config.assets.compile = true 

讓我知道你是否有什麼想法。謝謝。

+0

在production.rb中設置config.assets.compile = false並嘗試相同的步驟。由於上述配置,我猜每次網站加載時都會發生預編譯。 –

回答

0

運行以下命令在本地計算機:

RAILS_ENV=production rake assets:precompile 

然後按全部產生&清單文件中的Heroku。