Sha256: 33f6d8bb7915447fb1b979c43e89530bfd0bf4d64f2a4a4967cd5145a54db1bf
Contents?: true
Size: 1.47 KB
Versions: 16
Compression:
Stored size: 1.47 KB
Contents
module Gaku class TeachersController < GakuController include PictureController decorates_assigned :teacher respond_to :html, :js before_action :set_teacher, only: %i( edit show update destroy ) def destroy @teacher.destroy set_count respond_with @teacher end def new @teacher = Teacher.new respond_with @teacher end def create @teacher = Teacher.new(teacher_params) @teacher.save set_count respond_with @teacher end def edit respond_with @teacher end def show respond_with @teacher end def update @teacher.update(teacher_params) respond_with @teacher, location: [:edit, @teacher] end def index @search = Teacher.search(params[:q]) results = @search.result(distinct: true) @teachers = results.page(params[:page]) set_count respond_with @teachers end private def includes [[contacts: :contact_type, addresses: :country]] end def teacher_params params.require(:teacher).permit(attributes) end def attributes %i( name surname name_reading surname_reading birth_date gender picture ) end def set_teacher @teacher = Teacher.includes(includes).find(params[:id]) set_notable end def set_notable @notable = @teacher @notable_resource = get_resource_name @notable end def set_count @count = Teacher.count end end end
Version data entries
16 entries across 16 versions & 2 rubygems