mirror of
https://github.com/Threnklyn/Klaus.git
synced 2026-05-22 13:58:27 +02:00
Klaus V2.0
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user