Class: Nifty::Attachments::Attachment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Nifty::Attachments::Attachment
- Defined in:
- lib/nifty/attachments/attachment.rb
Instance Attribute Summary collapse
-
#uploaded_file ⇒ Object
This will be the ActionDispatch::UploadedFile object which be diseminated by the class on save.
Class Method Summary collapse
-
.for(role) ⇒ Object
Return the attachment for a given role.
Instance Method Summary collapse
-
#image? ⇒ Boolean
Is the attachment an image?.
-
#path ⇒ Object
Return the path to the attachment.
Instance Attribute Details
#uploaded_file ⇒ Object
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?
47 48 49 |
# File 'lib/nifty/attachments/attachment.rb', line 47 def image? file_type =~ /\Aimage\// end |
#path ⇒ Object
Return the path to the attachment
42 43 44 |
# File 'lib/nifty/attachments/attachment.rb', line 42 def path "/attachment/#{token}/#{file_name}" end |