Class: Gluttonberg::Admin::Settings::UsersController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- BaseController
- Gluttonberg::Admin::Settings::UsersController
- Defined in:
- app/controllers/gluttonberg/admin/settings/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 24 def create @user = User.new set_role @user.assign_attributes(params[:user]) if @user.save flash[:notice] = "Account registered!" redirect_to admin_users_path else render :action => :new end end |
#delete ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 58 def delete display_delete_confirmation( :title => "Delete “#{@user.email}” user?", :url => admin_user_path(@user), :return_url => admin_users_path ) end |
#destroy ⇒ Object
66 67 68 69 70 71 72 |
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 66 def destroy generic_destroy(@user, { :name => "user", :success_path => admin_users_path, :failure_path => admin_users_path }) end |
#edit ⇒ Object
38 39 40 |
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 38 def edit end |
#index ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 11 def index unless current_user.super_admin? || current_user.admin? redirect_to :action => "edit" , :id => current_user.id end @users = User.search_users(params[:query], current_user, get_order) @users = @users.paginate(:page => params[:page] , :per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items") ) end |
#new ⇒ Object
19 20 21 22 |
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 19 def new @user = User.new end |
#update ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 42 def update set_role if @user.update_attributes(params[:user]) flash[:notice] = "Account updated!" if current_user.super_admin? || current_user.admin? redirect_to admin_users_path else redirect_to :action => :edit end else flash[:notice] = "Failed to save account changes!" render :action => :edit end end |