Class: PageAttachment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/page_attachment.rb

Overview

Any user who can edit a Page can also upload attachments to that page. (Note: in this system a Page is the CMS pages that represent curriculum materials. A user can not upload an attachment to a team or a person page through this code.)

The attachments are stored on Amazon S3. S3 allows us to revision all documents. All old versions are still stored on the filesystem even though the user can only actively access the latest one.

When uploading a file, the user is asked for a “readable name” for the file: a label for the link to the file.

After uploading a file, the file's “readable name” can be updated or the file can be replaced. If the user replaces the an existing file (e.g. 'ppm_week1.ppt') with a different file name (e.g. 'ppm_week1_ts.ppt') then a warning appears. Any user who tries to access the original file name will not be able to do so. Under normal workflow, this isn't a big deal. It is possible for the user to create a link on the page to the old file and system will not automatically update it.

The system records who uploads and replaces the file and when this happens, and versions this information.

Class Method Summary collapse

Class Method Details

.reposition(ids) ⇒ Object

Re-position: change the sequence of attachments for a given page


38
39
40
# File 'app/models/page_attachment.rb', line 38

def self.reposition(ids)
  update_all(["position = STRPOS(?, ','||id||',')", ",#{ids.join(',')},"], {:id => ids})
end