Class: CaptainOveur::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CaptainOveur::UsersController
- Defined in:
- app/controllers/captain_oveur/users_controller.rb
Instance Method Summary collapse
- #activate_admin ⇒ Object
- #create ⇒ Object
- #deactivate_admin ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#activate_admin ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 56 def activate_admin @user = User.find(params[:id]) respond_to do |format| if @user.activate_admin! flash[:msg] = "User #{@user.email} was promoted to Admin." format.html do redirect_to edit_admin_user_path(@user) end else format.html do flash[:msg] = "User #{@user.email} could not be promoted to Admin." render :action => :edit end end end end |
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 15 def create @user = User.new(params[:user]) respond_to do |format| if @user.save flash[:msg] = "User created." format.html do redirect_to admin_user_path(@user) end else format.html do render :action => :new end end end end |
#deactivate_admin ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 73 def deactivate_admin @user = User.find(params[:id]) respond_to do |format| if @user.deactivate_admin! flash[:msg] = "User #{@user.email} was demoted from Admin." format.html do redirect_to edit_admin_user_path(@user) end else format.html do flash[:msg] = "User #{@user.email} could not be demoted from Admin." render :action => :edit end end end end |
#destroy ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 94 def destroy @user = User.find(params[:id]) respond_to do |format| if current_user.id != @user.id && @user.destroy flash[:msg] = "User deleted." else flash[:msg] = "User could not be deleted." end format.html do redirect_to admin_users_path end end end |
#edit ⇒ Object
31 32 33 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 31 def edit @user = User.find(params[:id]) end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 7 def index @users = User.all end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 11 def new @user = User.new end |
#show ⇒ Object
90 91 92 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 90 def show @user = User.find(params[:id]) end |
#update ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/captain_oveur/users_controller.rb', line 35 def update @user = User.find(params[:id]) if params[:user_admin] and params[:user_admin] == 1 @user.activate_admin! else @user.deactivate_admin! end respond_to do |format| if @user.update_attributes(params[:user]) flash[:msg] = "User #{@user.email} was successfully updated." format.html do redirect_to admin_users_path end else format.html do render :action => :edit end end end end |