2012-10-26 3 views
-1

paperclip-dropbox gem here을 사용하려고하는데 설정에 문제가 있고 자격 증명을 전달하는 중입니다.paperclip-dropbox gem이 잘못된 인수 유형을 throw합니다.

class User < ActiveRecord::Base 
    has_attached_file :avatar, 
    :storage => :dropbox, 
    :dropbox_credentials => "#{Rails.root}/config/dropbox.yml", 
    :dropbox_options => {...} 
end 

내 dropbox.yml 파일을 구성하고/config 폴더에 넣어했지만 나에게 파일이나 디렉토리 아무튼 말하고 레일 : 문서에서

는 모델의 설정과 같이 이루어집니다 존재하지 않습니다.

내가 환경 변수와 해시 내 자격 증명을 전달하는 경우, 스택 추적의

: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' 

다음 레일

는 "잘못된 인수 유형 문자열 PROC 예상"라고

저는 루비를 처음 접했고 procs를 이해하지 못했습니다. 작동 시키려면 어떻게 수정해야합니까?

+0

': dropbox_options'에 무엇이 있습니까? –

+0

오류의 전체 스택 추적을 추가 할 수 있습니까? –

+0

@ ZachKemp, : dropbox_options 해시 및 스택 추적을 추가했습니다. 스택 트레이스를 살펴본 후에, 나는 문제가 저를 저장하려고하는 경로와 함께 있다고 생각하기 시작했습니다. 어떤 아이디어? – akonwi

답변

2

readme에 따르면 paperclip-dropbox는 경로에 대한 proc를 예상합니다. 경로에있는 :avatar 매개 변수의 의미가 무엇입니까? 아니면 정적 인 부분입니까?

:path => proc { |style| "avatars/#{id}/#{style}/#{avatar.original_filename}" } 

당신은 또한 |style| 변수없이 시도 할 수 있지만 인수 오류 번호를 잘못 얻을 수 있습니다 :

난 당신이 이런 식으로 뭔가를 시도 할 필요가 있다고 생각합니다. 일반적으로 사이트에서 필요한 크기로 자동으로 이미지 크기를 조정하는 추가 스타일을 정의합니다. 자세한 내용은 docs을보십시오.

+0

정말 고마워요. 이미지 파일보다는 텍스트 파일을 저장하고 있기 때문에 필자가 필요로하는 부분에 맞게 작동하도록 구성했습니다. – akonwi