Class AdminsController
In: app/controllers/admins_controller.rb
lib/benchmarking/submission_files/admins_controller.rb
Parent: ApplicationController

Methods

create   create   edit   edit   index   index   populate   populate   update   update  

Included Modules

UsersHelper UsersHelper

Public Instance methods

Create a new Admin

[Source]

    # File lib/benchmarking/submission_files/admins_controller.rb, line 32
32:   def create
33:     return unless request.post?
34:     # Default attributes: role = TA or role = STUDENT
35:     # params[:user] is a hash of values passed to the controller 
36:     # by the HTML form with the help of ActiveView::Helper::
37:     @user = Admin.new(params[:user])
38:     # Return unless the save is successful; save inherted from
39:     # active records--creates a new record if the model is new, otherwise
40:     # updates the existing record
41:     return unless @user.save
42:     
43:     redirect_to :action => 'index'
44:   end

Create a new Admin

[Source]

    # File app/controllers/admins_controller.rb, line 33
33:   def create
34:     return unless request.post?
35:     # Default attributes: role = TA or role = STUDENT
36:     # params[:user] is a hash of values passed to the controller 
37:     # by the HTML form with the help of ActiveView::Helper::
38:     @user = Admin.new(params[:user])
39:     # Return unless the save is successful; save inherted from
40:     # active records--creates a new record if the model is new, otherwise
41:     # updates the existing record
42:     return unless @user.save
43:     
44:     redirect_to :action => 'index'
45:   end

[Source]

    # File lib/benchmarking/submission_files/admins_controller.rb, line 14
14:   def edit
15:     @user = Admin.find_by_id(params[:id]) 
16:   end

[Source]

    # File app/controllers/admins_controller.rb, line 14
14:   def edit
15:     @user = Admin.find_by_id(params[:id]) 
16:   end

[Source]

   # File lib/benchmarking/submission_files/admins_controller.rb, line 5
5:   def index
6:   end

[Source]

   # File app/controllers/admins_controller.rb, line 5
5:   def index
6:   end

[Source]

    # File lib/benchmarking/submission_files/admins_controller.rb, line 8
 8:   def populate
 9:     admins_data = Admin.find(:all, :order => "user_name")
10:     # construct_table_rows defined in UsersHelper
11:     @admins = construct_table_rows(admins_data)
12:   end

[Source]

    # File app/controllers/admins_controller.rb, line 8
 8:   def populate
 9:     admins_data = Admin.find(:all, :order => "user_name")
10:     # construct_table_rows defined in UsersHelper
11:     @admins = construct_table_rows(admins_data)
12:   end

[Source]

    # File lib/benchmarking/submission_files/admins_controller.rb, line 18
18:   def update
19:     return unless request.post?
20:     @user = Admin.find_by_id(params[:user][:id])
21:     attrs = params[:user]
22:     # update_attributes supplied by ActiveRecords
23:     if !@user.update_attributes(attrs)
24:       render :action => :edit
25:     else
26:       flash[:edit_notice] = @user.user_name + " has been updated."
27:       redirect_to :action => 'index'
28:     end
29:   end

[Source]

    # File app/controllers/admins_controller.rb, line 18
18:   def update
19:     return unless request.post?
20:     @user = Admin.find_by_id(params[:user][:id])
21:     attrs = params[:user]
22:     # update_attributes supplied by ActiveRecords
23:     if !@user.update_attributes(attrs)
24:       render :action => :edit
25:     else
26:       flash[:edit_notice] = I18n.t("admins.success", 
27:                                     :user_name => @user.user_name)
28:       redirect_to :action => 'index'
29:     end
30:   end

[Validate]