Sha256: 503fa8a678f7e9e91bb40aa9d79a56598665344def2960408bd1eb49b324647b

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

module Gaku
  class Students::SimpleGradesController < GakuController

    #skip_load_and_authorize_resource only: :index
    skip_authorization_check

    #load_and_authorize_resource :student, class: Gaku::Student
    #load_and_authorize_resource :simple_grade, through: :student, class: Gaku::SimpleGrade

    inherit_resources
    belongs_to :student
    respond_to :js, :html, :json

    before_filter :load_data
    before_filter :student
    before_filter :count, only: [:index, :create, :destroy, :update]
    before_filter :simple_grades, only: :update


    protected

    def collection
      @simple_grades ||= end_of_association_chain.accessible_by(current_ability)
    end

    def begin_of_association_chain
      @student
    end

    def resource_params
      return [] if request.get?
      [params.require(:simple_grade).permit(simple_grade_attr)]
    end

    private

    def simple_grade_attr
      %i(name grade school_id)
    end

    def load_data
      @schools = Gaku::School.all.map { |s| [s.name, s.id] }
    end

    def student
      @student = Student.find(params[:student_id])
    end

    def count
      @count = SimpleGrade.count
    end

    def simple_grades
      @simple_grades = @student.simple_grades
    end


  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
gaku_core-0.0.3 app/controllers/gaku/students/simple_grades_controller.rb
gaku-0.0.3 core/app/controllers/gaku/students/simple_grades_controller.rb
gaku-0.0.2 core/app/controllers/gaku/students/simple_grades_controller.rb
gaku_core-0.0.2 app/controllers/gaku/students/simple_grades_controller.rb
gaku-0.0.1 core/app/controllers/gaku/students/simple_grades_controller.rb
gaku_core-0.0.1 app/controllers/gaku/students/simple_grades_controller.rb