Sha256: 6046b1b2c8140add8f748298a2db297bda145f94dc61d01f23e4716e17a4bfc7
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
module Gaku class Students::StudentSpecialtiesController < GakuController #load_and_authorize_resource :student, class: Gaku::Student #load_and_authorize_resource :specialty, through: :student, class: Gaku::Specialty skip_authorization_check inherit_resources belongs_to :student respond_to :js, :html before_filter :load_data before_filter :student before_filter :student_specialties, only: :update before_filter :count, only: [:index, :create, :destroy, :update] def index @student_specialties = @student.student_specialties respond_with @student_specialties end def destroy super do |format| format.js { render } end end def resource_params return [] if request.get? [params.require(:student_specialty).permit(student_specialty_attr)] end private def student_specialty_attr %i(specialty_id major) end private def load_data @specialties = Gaku::Specialty.all.map { |s| [s.name, s.id] } end def student @student = Student.find(params[:student_id]) end def student_specialties student @student_specialties = @student.student_specialties end def count @count = StudentSpecialty.count end end end
Version data entries
6 entries across 6 versions & 2 rubygems