Rails Carrierwave& s3:参数个数错误(2个为1)

时间:2012-04-01 17:03:03

标签: ruby-on-rails amazon-s3 carrierwave fog

CarrierWave的新手,已经爱上了它,比Paperclip好多了。 Rails 3.2.1

我成功使用本地存储,但现在尝试转移到S3并在_url方法(或数据库列)上出现奇怪的错误

ArgumentError:参数数量错误(2表示1)

这是我的上传者:

class PictureUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick
  storage :fog
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
  process :resize_to_limit => [200, 200]
  def extension_white_list
    %w(jpg jpeg gif png)
  end
end

本地存储一切正常,S3 / fog将文件上传并调整为S3,我可以在桶中看到它;字段/ field_url方法似乎存在问题,它给出了错误(2为1)

我设置了非公开的s3:

CarrierWave.configure do |config|
  config.fog_credentials = {
  :provider               => 'AWS',       # required
  :aws_access_key_id      => 'xxx',       # required
  :aws_secret_access_key  => 'yyy',       # required
  :region                 => 'eu-west-1'  # optional, defaults to 'us-east-1'
 }
 config.fog_directory  = 'attachprod'                     # required
 config.fog_public     = false                                   # optional, defaults to true
end

这在我看来:

 <%= image_tag current_user.profile.picture_url %>

完整追踪:

ArgumentError: wrong number of arguments (2 for 1)  
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/fog-0.9.0/lib/fog/storage/models/aws/file.rb:126:in `url'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/carrierwave-0.6.0/lib/carrierwave/storage/fog.rb:148:in `authenticated_url'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/carrierwave-0.6.0/lib/carrierwave/storage/fog.rb:307:in `url'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/carrierwave-0.6.0/lib/carrierwave/uploader/url.rb:19:in `url'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/carrierwave-0.6.0/lib/carrierwave/uploader/versions.rb:159:in `url'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/carrierwave-0.6.0/lib/carrierwave/uploader/default_url.rb:8:in `url'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/carrierwave-0.6.0/lib/carrierwave/uploader/url.rb:27:in `to_s'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:47:in `start'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:8:in `start'
from /Users/boudewijnvandongen/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

任何想法,在任何地方找不到多少?

日Thnx

1 个答案:

答案 0 :(得分:3)

原来需要更新Fog gem到1.3.1现在好了