我想使用paperclip-dropbox寶石here,我遇到了設置問題並傳遞了我的憑據。paperclip-dropbox寶石拋出錯誤的參數類型
在文檔,模型的設定可以這樣判定:
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'
然後導軌說:「錯誤的參數類型爲String預計PROC」
我是新來的紅寶石,不太瞭解特效。我如何解決這個問題讓它起作用?
你在':dropbox_options'中有什麼? –
您能添加錯誤的完整堆棧跟蹤嗎? –
@ZachKemp,我添加了:dropbox_options哈希和堆棧跟蹤。在查看堆棧跟蹤之後,我開始認爲我的問題與我試圖保存的路徑一致。有任何想法嗎? – akonwi