【问题标题】:Paperclip & Fog: Getting 'NameError (uninitialized constant Fog):'回形针和雾:获取“名称错误(未初始化的常量雾):”
【发布时间】:2013-08-21 12:16:51
【问题描述】:

Paperclip/Fog 在我的本地机器 (Mac 10.8.4) 上工作,但在服务器 (Ubuntu 10.04 LTS) 上失败。我们一直在本地存储中使用回形针,但昨晚,迁移到云文件,我得到了这个:'uninitialized constant Fog' 错误。

控制台输出:

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'

宝石文件:

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

application.rb 文件:

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 文件:

class Project < ActiveRecord::Base
  attr_accessible :project_image

  has_attached_file :project_image, :styles => {:medium => "260x180#"}
end

【问题讨论】:

    标签: ruby ruby-on-rails-3.2 paperclip fog cloudfiles


    【解决方案1】:

    你能确认你已经安装了雾 gem 以及版本吗?

    您应该可以通过执行bundle show 来做到这一点。

    【讨论】:

    • 是的* fog (1.15.0).
    • 你是如何启动你的 Rails 服务器的? bundle exec rails s?
    • bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production
    • 我正在尝试使用回形针演示应用 (github.com/thoughtbot/paperclip_demo) 复制您的错误。我没有完全得到同样的错误,但我得到了类似的东西。 gist.github.com/krames/6272683。让我为你挖掘更多内容。
    • 我添加了gem 'excon`` to my Gemfile`,现在我得到了同样的uninitialized constant Fog 错误。我们可能发现了一个错误!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-04
    • 2015-05-03
    • 2016-07-15
    相关资源
    最近更新 更多