Created
November 3, 2008 16:57
-
-
Save roberto/21913 to your computer and use it in GitHub Desktop.
undefined
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
class Asset < ActiveRecord::Base | |
has_attached_file :local, | |
:styles => { :thumb => "100x100>" } | |
has_attached_file :remote, :styles => { :thumbnail => "100x100>" }, | |
:storage => :s3, :s3_credentials => RAILS_ROOT + "/config/s3.yml", | |
:bucket => "make-up-your-own-test-bucket", :path => ":class/:attachment/:id/:style.:extension" | |
validates_attachment_size :local, :in => 1.byte..10.megabyte | |
validates_attachment_presence :local | |
# for the views | |
def good_image | |
remote_file_name ? remote : local | |
end | |
def archive_to_remote | |
if local_file_name | |
self.remote = local.to_file | |
self.save | |
end | |
end | |
end | |
#source: http://pastie.org/187484 | |
#explanation: http://groups.google.com/group/paperclip-plugin/browse_thread/thread/8af52cc25cd97d02/05221d1a7254601d?lnk=gst&q=background |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment