Skip to content

Instantly share code, notes, and snippets.

@jdelStrother
Created April 17, 2009 17:01
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 jdelStrother/97130 to your computer and use it in GitHub Desktop.
Save jdelStrother/97130 to your computer and use it in GitHub Desktop.
class Attachment < ActiveRecord::Base
belongs_to :attachable, :polymorphic => true
has_attachment :storage => :file_system,
:file_system_path => "public/files/attachments",
:max_size => 100.megabytes
validates_as_attachment
#
# Override acts_as_attachment method for inherited classes. Just redefine attachment options instead.
#
class << self
alias_method :old_has_attachment, :has_attachment
def has_attachment(options)
self.attachment_options.merge!(options)
end
end
def thumb(thumbname = :thumb)
thumbnails.find(:first, :conditions => ['thumbnail=?', thumbname.to_s])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment