Klaus V2.0

This commit is contained in:
Florian Bogenhard
2014-08-11 01:35:48 +02:00
parent 4a1a0937d4
commit cedeffd2c6
55 changed files with 1267 additions and 40 deletions
+31 -3
View File
@@ -1,6 +1,8 @@
class DocumentsController < ApplicationController
before_filter :authenticate_user!, :only => [:destroy, :edit, :update ]
def index
@documents_grid = initialize_grid(Document)
@documents_grid = initialize_grid(Document, include: [:lesson, :doc_type, :semester, :professor])
end
def new
@@ -13,13 +15,39 @@ class DocumentsController < ApplicationController
if @document.save
redirect_to documents_path, notice: 'Document was successfully created.'
else
lash.now[:alert] = 'Document creation failed.'
flash.now[:alert] = 'Document creation failed.'
render 'new'
end
end
def edit
@document = Document.find(params[:id])
end
def update
@document = Document.find(params[:id])
if @document.update(document_update_params)
redirect_to documents_path, notice: 'Document was successfully updated.'
else
flash.now[:alert] = 'Document update failed.'
render 'new'
end
end
def destroy
@document = Document.find(params[:id])
@document.destroy
redirect_to documents_path, notice: 'Document was successfully destroyed.'
end
private
def document_params
params.require(:document).permit(:name)
params.require(:document).permit(:doc_type_id, :semester_id, :professor_id, :file, :file_cache, :lesson_id)
end
def document_update_params
params.require(:document).permit(:doc_type_id, :semester_id, :professor_id, :lesson_id)
end
end