Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UsersController
- Defined in:
- lib/branston/app/controllers/users_controller.rb,
lib/branston/test/functional/users_controller_test.rb
Overview
Re-raise errors caught by the controller.
Instance Method Summary collapse
- #activate ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #rescue_action(e) ⇒ Object
- #suspend ⇒ Object
- #update ⇒ Object
Instance Method Details
#activate ⇒ Object
63 64 65 66 |
# File 'lib/branston/app/controllers/users_controller.rb', line 63 def activate @user.activate! redirect_to users_path end |
#create ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/branston/app/controllers/users_controller.rb', line 32 def create @user = User.new(params[:user]) @user.role = params[:user][:role] if current_user.has_role?("admin") if @user && @user.valid? && @user.save! redirect_to users_url flash[:notice] = "User created." else flash[:error] = "We couldn't set up that account, sorry. Please try again, or contact an admin (link is above)." render :action => 'new' end end |
#destroy ⇒ Object
68 69 70 71 |
# File 'lib/branston/app/controllers/users_controller.rb', line 68 def destroy @user.delete! redirect_to users_path end |
#edit ⇒ Object
44 45 46 |
# File 'lib/branston/app/controllers/users_controller.rb', line 44 def edit @user = User.find(params[:id]) end |
#index ⇒ Object
24 25 26 |
# File 'lib/branston/app/controllers/users_controller.rb', line 24 def index @users = User.find(:all) end |
#new ⇒ Object
28 29 30 |
# File 'lib/branston/app/controllers/users_controller.rb', line 28 def new @user = User.new end |
#rescue_action(e) ⇒ Object
5 |
# File 'lib/branston/test/functional/users_controller_test.rb', line 5 def rescue_action(e) raise e end |
#suspend ⇒ Object
58 59 60 61 |
# File 'lib/branston/app/controllers/users_controller.rb', line 58 def suspend @user.suspend! redirect_to users_path end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/branston/app/controllers/users_controller.rb', line 48 def update @user = User.find(params[:id]) @user.role = params[:user][:role] if current_user.has_role?("admin") if @user.update_attributes(params[:user]) redirect_to users_path else render :action => 'edit' end end |