2
votes

Error message of my server

A NameError occurred in..

uninitialized constant CarrierWave::Video app/uploaders/video_uploader.rb:7:in
<class:VideoUploader>'

video_uploader.rb:7 => include CarrierWave::Video

INFO :

  1. In my local, it works(development & production mode)! But after deploy to server, occur that error.

  2. But in my server rails c production,
    Input 'include CarrierWave::Video' then Rails Console print not 'NameError: uninitialized constant..' but 'Object'. This means 'include CarrierWave::Video' succeeded!!

  3. Of course, these gem(gem 'carrierwave' , gem 'carrierwave-video') is in my Gemfile and Gemfile.lock and bundle install success.(when deploy)
    So in my_app/shared/bundle/ruby/2.0.0, GEM_HOME & GEM_PATH of my app, exist these gems

  4. I think 'include' doesn't work. because Like this, i have been met this error at line 'include CarrierWave::RMagick' when using gem 'rmagick' to resize image file uploaded.
    Of course, this is not solved yet..

  5. Purely CarrierWave removed line 'include ~~' works well (ex : Image upload not resized..)

  6. nginx + unicorn, linux ubuntu 12.04

Please help me.. T^T
i dont know why 'include CarrierWave::Video' not work in .rb file but work in rails console..

ADDED :

  1. 'require' about these gems not exist in my code(in application.rb.. etc..),
    (require 'carrierwave/video'.)

  2. If add "require 'carrierwave/video'" to application.rb below require 'rails/all',
    occured my application is now worked all. If add to video_uploader.rb and I request page using video_uploader , then occur error cannot such file bulabula..

2

2 Answers

2
votes

This error caused by your server didn't reload the module.

Just restart your rails server, and everything will go right. Make sure you are loading CarrierWave after loading your ORM.

0
votes

If you added gem 'carrierwave' do this rails generate uploader UPLOADER_NAME