uninitialized constant CarrierWave

淺唱寂寞╮ 提交于 2019-12-07 10:23:32

问题


I am deploying my first rails app using passenger and capistrano.

every thing is fine until i faced this error when I tried to launch the app in the browser.

Error message:
   uninitialized constant CarrierWave

Exception class:
   NameError

you can see the message in details at http://test.ajhezaty.com/

the site works perfectly locally and CarrierWave uploading the image correctly.

I tried to restart the VPS server by running

sudo /etc/init.d/httpd2 restart

but it didnt fix the issue.

for your information the gem installed on the server

 $ gem list | grep carrierwave
 carrierwave (0.6.1)

回答1:


You need to add carrierwave to your application.rb file like this:

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

require 'rails/all'

require 'carrierwave'

if defined?(Bundler)
  # Bundler stuff
end

# Rest of file ommited.

This worked for me in production using nginx/unicorn. Don't forget to restart your unicorn server.




回答2:


You may have the gem installed locally, but make sure you add it to your Gemfile, bundle install through ssh, and require it in the controllers that will use it.



来源:https://stackoverflow.com/questions/10116953/uninitialized-constant-carrierwave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!