Class: Nifty::Attachments::Attachment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/nifty/attachments/attachment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#uploaded_fileObject

This will be the ActionDispatch::UploadedFile object which be diseminated by the class on save.



10
11
12
# File 'lib/nifty/attachments/attachment.rb', line 10

def uploaded_file
  @uploaded_file
end

Class Method Details

.for(role) ⇒ Object

Return the attachment for a given role



37
38
39
# File 'lib/nifty/attachments/attachment.rb', line 37

def self.for(role)
  self.where(:role => role).first
end

Instance Method Details

#image?Boolean

Is the attachment an image?

Returns:

  • (Boolean)


47
48
49
# File 'lib/nifty/attachments/attachment.rb', line 47

def image?
  file_type =~ /\Aimage\//
end

#pathObject

Return the path to the attachment



42
43
44
# File 'lib/nifty/attachments/attachment.rb', line 42

def path
  "/attachment/#{token}/#{file_name}"
end