|
|
@ -61,12 +61,12 @@ class DocumentsController < ApplicationController |
|
|
|
|
|
|
|
|
|
|
|
def new |
|
|
|
def new |
|
|
|
@document = @project.documents.build |
|
|
|
@document = @project.documents.build |
|
|
|
@document.safe_attributes = params[:document] |
|
|
|
@document.attributes = document_params |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def create |
|
|
|
def create |
|
|
|
@document = @project.documents.build |
|
|
|
@document = @project.documents.build |
|
|
|
@document.safe_attributes = params[:document] |
|
|
|
@document.attributes = document_params |
|
|
|
if @document.save |
|
|
|
if @document.save |
|
|
|
attachments = Attachment.attach_files(@document, params[:attachments]) |
|
|
|
attachments = Attachment.attach_files(@document, params[:attachments]) |
|
|
|
render_attachment_warning_if_needed(@document) |
|
|
|
render_attachment_warning_if_needed(@document) |
|
|
@ -82,7 +82,7 @@ class DocumentsController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def update |
|
|
|
def update |
|
|
|
@document.safe_attributes = params[:document] |
|
|
|
@document.attributes = document_params |
|
|
|
if @document.save |
|
|
|
if @document.save |
|
|
|
flash[:notice] = l(:notice_successful_update) |
|
|
|
flash[:notice] = l(:notice_successful_update) |
|
|
|
redirect_to :action => 'show', :id => @document |
|
|
|
redirect_to :action => 'show', :id => @document |
|
|
@ -108,4 +108,9 @@ class DocumentsController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
redirect_to :action => 'show', :id => @document |
|
|
|
redirect_to :action => 'show', :id => @document |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
def document_params |
|
|
|
|
|
|
|
params.require(:document).permit('category_id', 'title', 'description') |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|