Skip to content

Instantly share code, notes, and snippets.

@duykhoa
Last active August 29, 2015 14:15
Show Gist options
  • Save duykhoa/0f433b88fd57871b28fb to your computer and use it in GitHub Desktop.
Save duykhoa/0f433b88fd57871b28fb to your computer and use it in GitHub Desktop.
Custom paperclip storage in model
module PaperclipStorageOption
module ClassMethods
def options
Rails.env.production? ? production_options : default_options
end
private
def production_options
{
storage: :dropbox,
dropbox_credentials: Rails.root.join("config/dropbox.yml")
}
end
def default_options
{}
end
end
extend ClassMethods
end
has_attached_file :image, { :styles => { :medium => "1200x800>" } }.merge(PaperclipStorageOption.options)
@codeinmotion
Copy link

So awesome! I felt terrible with the paperclip storage for 3 days. Thanks for sharing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment