Module: PageAttachmentAssociations::InstanceMethods

Defined in:
app/models/page_attachment_associations.rb

Instance Method Summary collapse

Instance Method Details

#attachment(name) ⇒ Object

Currently recursive, but could be simplified with some SQL



15
16
17
18
# File 'app/models/page_attachment_associations.rb', line 15

def attachment(name)
  att = attachments.find(:first, :conditions => ["filename LIKE ?", name.to_s])
  att.blank? ? ((parent.attachment(name) if parent) or nil) : att
end