0

Paperclip/Fog works on my local machine (Mac 10.8.4), but fails on server (Ubuntu 10.04 LTS). We have been using paperclip fine with local storage, but last night, migrated to cloud files and I'm getting this: 'uninitialized constant Fog' error.

Console Output:

Started PUT "/projects/car-tournament-of-champions-catoc" for 70.112.118.118 at 2013-08-19 06:44:57 +0000
Processing by ProjectsController#update as HTML
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"dwYOstjhuj2npLioC2rcXBKQ4lhGMlLt8s+epBm5vzk=", "project"=>{"name"=>"Car Tournament of Champions™ (CATOC™)", "headline"=>"Introducing true audiophile sound to the automotive environment", "about"=>"Car Audio Tournament of Champions (CATOC) is the world leader in premium sound system evaluation and marketing", "project_image"=>#<ActionDispatch::Http::UploadedFile:0x000000064a96c8 @original_filename="CATOC_MAIN_K.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"project[project_image]\"; filename=\"CATOC_MAIN_K.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20130819-4418-97i2l5>>, "category_id"=>"1", "paypal_email"=>"pre-registration@catoc-cca.com", "extra_amount"=>"0", "extend_days"=>"0"}, "button"=>"", "id"=>"car-tournament-of-champions-catoc"}
Completed 500 Internal Server Error in 12ms

NameError (uninitialized constant Fog):
  app/controllers/projects_controller.rb:387:in `block in update'
  app/controllers/projects_controller.rb:386:in `update'

Gemfile:

gem 'rails', '3.2.3' #ruby 1.9.3-p194
gem 'fog'
gem 'paperclip', '~> 3.0'

application.rb file:

config.paperclip_defaults = {
    :path => "images/:class/:id/:attachment/:style/img_:fingerprint",
    :storage => :fog,
    :fog_credentials => {
        :provider           => 'Rackspace',
        :rackspace_username => '<rackspace userid>',
        :rackspace_api_key  => '<rackspace api key>',
        :region => 'dfw',
        :persistent => false
    },
    :fog_directory => "prod_image_container",
    :fog_public => true,
    :fog_host => "http://c8d0f182112c0c3e585e-d37a976c417d5d9c71ba0df711c60fa4.r4.cf1.rackcdn.com"
}

project.rb file:

class Project < ActiveRecord::Base
  attr_accessible :project_image

  has_attached_file :project_image, :styles => {:medium => "260x180#"}
end
Miriam H.
  • 671
  • 2
  • 8
  • 25

1 Answers1

0

Can you verify that you have installed the fog gem as well as the version?

You should be able to do this by executing bundle show.

Kyle Rames
  • 398
  • 2
  • 5
  • yep `* fog (1.15.0)`. – Miriam H. Aug 19 '13 at 17:12
  • How are you launching your rails server? `bundle exec rails s`? – Kyle Rames Aug 19 '13 at 17:50
  • `bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production` – Miriam H. Aug 19 '13 at 17:56
  • I am attempting to duplicate your error using the paperclip_demo app (https://github.com/thoughtbot/paperclip_demo). I didn't quite get the same error, but I got something similar. https://gist.github.com/krames/6272683. Let me dig in a bit more for you. – Kyle Rames Aug 19 '13 at 18:55
  • I added `gem 'excon`` to my `Gemfile` and now I am getting the same `uninitialized constant Fog` error. We might have found a bug! – Kyle Rames Aug 19 '13 at 19:06
  • I am wondering if it could be that I am using older versions of Ruby or Rails or Ubuntu too? – Miriam H. Aug 19 '13 at 19:17
  • I managed to get mine to work by changing `region` to `rackspace_region` in your `application.rb`. If that still doesn't work let me know and I can try to fire this up on an Ubuntu instance. – Kyle Rames Aug 19 '13 at 19:20
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/35792/discussion-between-kyle-rames-and-michael-h) – Kyle Rames Aug 19 '13 at 19:31
  • Or if you're like me, maybe you just need to restart your server. – Navid Khan Oct 21 '19 at 15:11