Class: Spud::Admin::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Spud::Admin::UsersController
- Defined in:
- app/controllers/spud/admin/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/spud/admin/users_controller.rb', line 31 def create status = 500 @user = SpudUser.new(params[:spud_user]) @user.super_admin = params[:spud_user][:super_admin] if @user.save status = 200 flash[:notice] = "User created successfully" else flash[:error] = "There was an error while saving the user." render :action => "new" end respond_to do |format| format.js { render :status => status, :json => @user.to_json} format.html { if status == 200 redirect_to spud_admin_users_url() else render :action => "new" end } end end |
#destroy ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/spud/admin/users_controller.rb', line 84 def destroy status = 500 if @user.destroy status = 200 flash[:notice] = "User removed." else flash[:error] = "There was an error removing the user" end respond_to do |format| format.js { render :text => nil,:status => status } format.html {redirect_to spud_admin_users_url()} end end |
#edit ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/spud/admin/users_controller.rb', line 58 def edit Spud::Core.admin_applications.each do |application| = @user..select {|perm| perm.name == application[:name]} if .blank? @user..new(:name => application[:name],:access => @user.super_admin) end end respond_to do |format| format.js { render :partial => "edit"} format.html { render } end end |
#index ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/spud/admin/users_controller.rb', line 9 def index @users = SpudUser.order(:login).paginate :page => params[:page] respond_with @users end |
#new ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/spud/admin/users_controller.rb', line 19 def new @user = SpudUser.new Spud::Core.admin_applications.each do |application| @user..new(:name => application[:name],:access => false) end respond_with @user do |format| format.js { render :partial => "new"} end end |
#show ⇒ Object
15 16 17 18 |
# File 'app/controllers/spud/admin/users_controller.rb', line 15 def show @user.full_name, :spud_admin_user_path respond_with @user end |
#update ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/spud/admin/users_controller.rb', line 71 def update @user.attributes = params[:spud_user] @user.super_admin = params[:spud_user][:super_admin] if @user.save flash[:notice] = "User saved successfully." redirect_to spud_admin_users_url() else flash[:error] = "There was an error while saving the user." render :action => "edit" end end |