Last active
August 29, 2015 14:15
-
-
Save duykhoa/0f433b88fd57871b28fb to your computer and use it in GitHub Desktop.
Custom paperclip storage in model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has_attached_file :image, { :styles => { :medium => "1200x800>" } }.merge(PaperclipStorageOption.options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So awesome! I felt terrible with the paperclip storage for 3 days. Thanks for sharing it!