Hash Carrierwave+;雾(S3)和#x2B;Heroku:TypeError(无法将散列转换为字符串)

Hash Carrierwave+;雾(S3)和#x2B;Heroku:TypeError(无法将散列转换为字符串),hash,heroku,amazon-s3,carrierwave,fog,Hash,Heroku,Amazon S3,Carrierwave,Fog,我在Heroku上有一个应用程序,它使用Carrierwave将图像上传到S3。该应用程序在本地计算机上运行良好,但在Heroku上出现以下错误,无法上载到S3: TypeError (can't convert Hash into String): 2011-09-23T15:12:07+00:00 app[web.1]: app/controllers/admin/albums_controller.rb:49:in `create' 2011-09-23T15:12:07+00:00

我在Heroku上有一个应用程序,它使用Carrierwave将图像上传到S3。该应用程序在本地计算机上运行良好,但在Heroku上出现以下错误,无法上载到S3:

TypeError (can't convert Hash into String):
2011-09-23T15:12:07+00:00 app[web.1]:   app/controllers/admin/albums_controller.rb:49:in `create'
2011-09-23T15:12:07+00:00 app[web.1]:   app/controllers/admin/albums_controller.rb:48:in `create'
该行对应于“if@album.save”指令

My Albums controller创建操作是:

def create
@album = Album.new(params[:album])

respond_to do |format|
  if @album.save
    format.html { redirect_to(admin_album_path(@album), :notice => 'Àlbum creat correctament.') }
    format.xml  { render :xml => [:admin, @album], :status => :created, :location => @album }
  else
    format.html { render :action => "new" }
    format.xml  { render :xml => @album.errors, :status => :unprocessable_entity }
  end
end
end
我的Carrierwave初始值设定项:

CarrierWave.configure do |config|
    config.fog_credentials = {
      :provider               => 'AWS', 
      :aws_access_key_id      => APP_CONFIG['storage']['s3_access'],
      :aws_secret_access_key  => APP_CONFIG['storage']['s3_secret'],
    }
    config.fog_directory  = 'romeu'
    config.fog_host       = 'http://xxxxx.s3.amazonaws.com'
    config.fog_public     = true
    config.root = Rails.root.join('tmp')
    config.cache_dir = 'carrierwave'
end
My image_uploader.rb:

class ImageUploader < CarrierWave::Uploader::Base

include CarrierWave::MiniMagick

storage :fog

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

# Album Cover version
version :cover do
  process :square_resize => [150,150]
end

# Thumb version
version :thumb do
  process :square_crop => [80,80]
end

def square_crop(width, height)
  manipulate! do |img|
    side = [img['width'], img['height']].min
    x = (img['width'] - side) / 2
    y = (img['height'] - side) / 2
    img.crop("#{side}x#{side}+#{x}+#{y}")
    img.resize("#{width}x#{height}")
    img
  end
end

def square_resize(width, height)
  manipulate! do |img|
    img.resize("#{width}x#{height}")
    img
  end
end

# Valid list
def extension_white_list
    %w(jpg jpeg gif png)
end
end
我已经检查了@album对象,似乎一切正常:

_mounters: 
  :image: !ruby/object:CarrierWave::Mount::Mounter 
    _memoized_option: 
      ? 
        - :mount_on
      : 

    column: :image
    integrity_error: 
    options: {}

    processing_error: 
    record: *id001
    uploader: !ruby/object:ImageUploader 
      cache_id: 20110923-0810-1-0644
      file: !ruby/object:CarrierWave::SanitizedFile 
        content_type: image/jpeg
        file: /app/tmp/carrierwave/20110923-0810-1-0644/image.jpg
        original_filename: 
      filename: image.jpg
      model: *id001
      mounted_as: :image
      original_filename: image.jpg
      versions: 
        :thumb: !ruby/object: 
          file: !ruby/object:CarrierWave::SanitizedFile 
          cache_id: 20110923-0810-1-0644
            content_type: image/jpeg
            file: /app/tmp/carrierwave/20110923-0810-1-0644/image.jpg
            original_filename: 
          filename: image.jpg
          model: *id001
          mounted_as: :image
          original_filename: image.jpg
          parent_cache_id: 20110923-0810-1-0644
          versions: {}

        :cover: !ruby/object: 
          cache_id: 20110923-0810-1-0644
          file: !ruby/object:CarrierWave::SanitizedFile 
            content_type: image/jpeg
            file: /app/tmp/carrierwave/20110923-0810-1-0644/image.jpg
            original_filename: 
          filename: image.jpg
          model: *id001
          mounted_as: :image

attributes: 

  title: 
  body: 
    model: *id001
previously_changed: {}
readonly: false
我花了很多天的时间试图解决这个错误,但没有成功,我错过了什么?
提前谢谢。

经过长时间的工作,我已经解决了这个问题。这就像Heroku上S3访问键的环境变量被错误定义一样愚蠢。我不明白为什么Fog gem不能为您提供关于此类错误的更准确的调试信息。

尝试将Fog_目录的http更改为https,文档中就是这样的,我想您指的是Fog_主机而不是Fog_目录,但我已经尝试过了,我也遇到了同样的问题。现在我想知道我是否在AmazonS3上设置了正确的权限,你知道什么是正确的配置吗?谢谢
_mounters: 
  :image: !ruby/object:CarrierWave::Mount::Mounter 
    _memoized_option: 
      ? 
        - :mount_on
      : 

    column: :image
    integrity_error: 
    options: {}

    processing_error: 
    record: *id001
    uploader: !ruby/object:ImageUploader 
      cache_id: 20110923-0810-1-0644
      file: !ruby/object:CarrierWave::SanitizedFile 
        content_type: image/jpeg
        file: /app/tmp/carrierwave/20110923-0810-1-0644/image.jpg
        original_filename: 
      filename: image.jpg
      model: *id001
      mounted_as: :image
      original_filename: image.jpg
      versions: 
        :thumb: !ruby/object: 
          file: !ruby/object:CarrierWave::SanitizedFile 
          cache_id: 20110923-0810-1-0644
            content_type: image/jpeg
            file: /app/tmp/carrierwave/20110923-0810-1-0644/image.jpg
            original_filename: 
          filename: image.jpg
          model: *id001
          mounted_as: :image
          original_filename: image.jpg
          parent_cache_id: 20110923-0810-1-0644
          versions: {}

        :cover: !ruby/object: 
          cache_id: 20110923-0810-1-0644
          file: !ruby/object:CarrierWave::SanitizedFile 
            content_type: image/jpeg
            file: /app/tmp/carrierwave/20110923-0810-1-0644/image.jpg
            original_filename: 
          filename: image.jpg
          model: *id001
          mounted_as: :image

attributes: 

  title: 
  body: 
    model: *id001
previously_changed: {}
readonly: false