2

我得到了它存儲User化身在public/uploads DIR一個class AvatarUploader < Carrierwave::Uploader::Base的Rails 3.2 Carrierwave預編譯錯誤

def store_dir 
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" 
    end 

    version :main do 
    process :resize_to_limit => [128, 128] 
    end 

而且我想與資產預編譯啓用了production模式啓動應用程序。一切,但頭像工作正常。當我訪問任何User簡介我得到:

Started GET "https://stackoverflow.com/users/1" for 127.0.0.1 at 2012-05-03 17:45:24 +0300 
Processing by Users::UsersController#show as HTML 
    Parameters: {"id"=>"1"} 
    Rendered users/users/show.html.erb within layouts/application (2.5ms) 
Completed 500 Internal Server Error in 16ms 

ActionView::Template::Error (isn't precompiled): 
    87:      <%= image_tag @user.avatar_url(:main).to_s %> 
    app/views/users/users/show.html.erb:87:in `_app_views_users_users_show_html_erb___538221278131396366_28399560' 

也許有關閉預編譯的虛擬形象(因爲他們可以在應用程序是在生產環境中運行重新上傳)的方式。請提供任何建議如何解決此問題。謝謝。

回答

7

當IMAGE_TAG會收到一個空字符串,它試圖從資產管道獲取資源 並返回

「不預編譯」

https://github.com/rails/rails/issues/3080

打印@user.avatar_url(:main).to_s到仔細檢查

+0

我檢查網址,它是空白的(現在我會尋找一個解決方案。謝謝你的幫助! –