Skip to content

Instantly share code, notes, and snippets.

@darcyclark
Created February 26, 2014 13:45
Show Gist options
  • Save darcyclark/9229701 to your computer and use it in GitHub Desktop.
Save darcyclark/9229701 to your computer and use it in GitHub Desktop.
def update
@document = Document.find(params[:document_id])
@version = @document.document_versions.find(params[:id])
authorize_action_for(@version, parent_project)
if @version.update_attributes(version_params)
if !params[:version][:file].blank?
# store document and project id in file so we can get to them later for permissions checking when file is served
@version.reload
@version.file.add_meta('attachable_type' => @document.class.to_s)
@version.file.add_meta('attachable_uid' => @document.id.to_s)
@version.file.add_meta('project_uid' => params[:project_id])
@version.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment