I’m trying to use the paperclip-dropbox gem here, and I’m having issues with the setup and passing my credentials.
In the documentation, the setup in the model is done like so:
class User < ActiveRecord::Base
has_attached_file :avatar,
:storage => :dropbox,
:dropbox_credentials => "#{Rails.root}/config/dropbox.yml",
:dropbox_options => {...}
end
I have configured my dropbox.yml file and put in the /config folder but rails is telling me the file or directory doesn’t exist.
If I pass my credentials in the hash with the environment variables,
: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"
}
The top of the stack trace is:
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'
then rails says “wrong argument type String expected Proc”
I’m new to ruby and don’t quite understand procs. How do I fix this to get it to work?
According to the readme, paperclip-dropbox expects a proc for the path. Does the
:avatarparameter in your path mean anything, or is that meant to be a static portion?I think you need to try something like this:
You also can try it without the
|style|variable, but you might get a wrong number of arguments error. Typically, one would define additional styles to automatically scale images to the sizes you need on your site – have a look at the docs for more info.