Skip to content

Instantly share code, notes, and snippets.

@roberto
Created November 3, 2008 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roberto/21913 to your computer and use it in GitHub Desktop.
Save roberto/21913 to your computer and use it in GitHub Desktop.
undefined
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