Class: GradesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- GradesController
- Defined in:
- app/controllers/grades_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #deny_to_visitors ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
31 32 33 34 35 |
# File 'app/controllers/grades_controller.rb', line 31 def create grade = Grade.new(grades_params) grade.save redirect_to '/grades' end |
#deny_to_visitors ⇒ Object
27 28 29 |
# File 'app/controllers/grades_controller.rb', line 27 def deny_to_visitors redirect_to "/signin" unless user_signed_in? && !current_user.admin? end |
#edit ⇒ Object
8 9 10 |
# File 'app/controllers/grades_controller.rb', line 8 def edit @grade = Grade.find(params[:id]) end |
#index ⇒ Object
23 24 25 |
# File 'app/controllers/grades_controller.rb', line 23 def index @grades = Grade.all end |
#new ⇒ Object
4 5 6 |
# File 'app/controllers/grades_controller.rb', line 4 def new end |
#update ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/grades_controller.rb', line 12 def update @grade = Grade.find(params[:id]) binding.pry if @grade.update_attributes(grades_params) redirect_to :action => 'index' else flash[:alert] = "Required fields are missing." redirect_to :action => 'edit', :id => @grade end end |