Created
February 26, 2014 13:45
-
-
Save darcyclark/9229701 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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