Module: Attach::Attachment
- Defined in:
- lib/attach/attachment.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #delete_files ⇒ Object
- #dir ⇒ Object
- #path(format = :full) ⇒ Object
-
#url(format = :full) ⇒ Object
module ClassMethods.
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 |
# File 'lib/attach/attachment.rb', line 4 def included(klass) klass.extend(ClassMethods) klass.before(:destroy, :delete_files) end |
Instance Method Details
#delete_files ⇒ Object
47 48 49 |
# File 'lib/attach/attachment.rb', line 47 def delete_files FileUtils.rmtree(self.dir) end |
#dir ⇒ Object
39 40 41 |
# File 'lib/attach/attachment.rb', line 39 def dir "public/assets/#{self.id}" end |
#path(format = :full) ⇒ Object
43 44 45 |
# File 'lib/attach/attachment.rb', line 43 def path(format = :full) "#{self.dir}/#{format}/#{self.filename}" end |
#url(format = :full) ⇒ Object
module ClassMethods
35 36 37 |
# File 'lib/attach/attachment.rb', line 35 def url(format = :full) "/assets/#{self.id}/#{format}/#{self.filename}" end |