Created
April 17, 2009 17:01
-
-
Save jdelStrother/97130 to your computer and use it in GitHub Desktop.
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 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