Sha256: 34fdf61703167f5421f03e9c494864af35e8002dfb0bd3da5d991344412086b4
Contents?: true
Size: 1.44 KB
Versions: 4
Compression:
Stored size: 1.44 KB
Contents
module Gaku class NotesController < GakuController #load_and_authorize_resource :note, class: Gaku::Note before_action :set_notable before_action :set_note, only: %i( edit update destroy ) respond_to :js def new @note = Note.new respond_with @note end def create @note = @notable.notes.new(note_params) @note.save set_count respond_with @note end def edit end def show end def update @note.update(note_params) respond_with @note end def destroy @note.destroy set_count respond_with @note end private def note_params params.require(:note).permit(note_attr) end def note_attr %i(title content) end def notable_klasses [ Gaku::Student, Gaku::Teacher, Gaku::LessonPlan, Gaku::Syllabus, Gaku::ClassGroup, Gaku::Course, Gaku::Exam ] end def set_count @count = @notable.reload.notes_count end def set_note @note = Note.find(params[:id]) end def set_notable unnamespaced_klass = '' klass = notable_klasses.find do |c| unnamespaced_klass = c.to_s.split('::') params["#{unnamespaced_klass[1].underscore}_id"] end @notable = klass.find(params["#{unnamespaced_klass[1].underscore}_id"]) @notable_resource = get_resource_name @notable end end end
Version data entries
4 entries across 4 versions & 2 rubygems