我正在尝试在这里使用回形针保管箱 gem ,但我在设置和传递我的凭据时遇到了问题。
在文档中,模型中的设置是这样完成的:
class User < ActiveRecord::Base
has_attached_file :avatar,
:storage => :dropbox,
:dropbox_credentials => "#{Rails.root}/config/dropbox.yml",
:dropbox_options => {...}
end
我已经配置了我的 dropbox.yml 文件并将其放入 /config 文件夹,但 rails 告诉我该文件或目录不存在。
如果我使用环境变量在哈希中传递我的凭据,
:dropbox_credentials => {
app_key: ENV["DROPBOX_APP_KEY"],
app_secret: ENV["DROPBOX_APP_SECRET"],
access_token: ENV["DROPBOX_ACCESS_TOKEN"],
access_token_secret: ENV["DROPBOX_ACCESS_TOKEN_SECRET"],
user_id: ENV["DROPBOX_USER_ID"]
}
:dropbox_options => {
:path => ":attachment/:id/:basename.:extension"
}
堆栈跟踪的顶部是:
paperclip-dropbox (1.0.0) lib/paperclip/storage/dropbox.rb:59:in `path_for_url'
paperclip-dropbox (1.0.0) lib/paperclip/storage/dropbox.rb:55:in `path'
paperclip-dropbox (1.0.0) lib/paperclip/storage/dropbox.rb:41:in `exists?'
paperclip (3.2.0) lib/paperclip/attachment.rb:436:in `block in queue_all_for_delete'
paperclip (3.2.0) lib/paperclip/attachment.rb:435:in `map'
paperclip (3.2.0) lib/paperclip/attachment.rb:435:in `queue_all_for_delete'
paperclip (3.2.0) lib/paperclip/attachment.rb:213:in `clear'
paperclip (3.2.0) lib/paperclip/attachment.rb:94:in `assign'
paperclip (3.2.0) lib/paperclip.rb:196:in `block in has_attached_file'
activerecord (3.2.6) lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
activerecord (3.2.6) lib/active_record/attribute_assignment.rb:78:in `each'
activerecord (3.2.6) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
activerecord (3.2.6) lib/active_record/persistence.rb:212:in `block in update_attributes'
activerecord (3.2.6) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.2.6) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
activerecord (3.2.6) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.6) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.6) lib/active_record/persistence.rb:211:in `update_attributes'
app/controllers/users_controller.rb:45:in `update'
然后 rails 说“错误的参数类型字符串预期 Proc”
我是 ruby 新手,不太了解 procs。我该如何解决这个问题才能让它工作?