Class: Alchemy::Admin::UsersController
- Inherits:
-
ResourcesController
- Object
- ResourcesController
- Alchemy::Admin::UsersController
- Defined in:
- app/controllers/alchemy/admin/users_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 46 def create @user = User.new(user_params) if while_signup? signup_admin_or_redirect(@user) else create_user_or_redirect(@user) end end |
#destroy ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 69 def destroy # User is fetched via before filter name = @user.name if @user.destroy flash[:notice] = _t("User deleted", name: name) end do_redirect_to admin_users_path end |
#index ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 20 def index if params[:query].present? @users = User.search(params[:query]) else @users = User.all end @users = @users .page(params[:page] || 1) .per(per_page_value_for_screen_size) .order(sort_order) end |
#new ⇒ Object
33 34 35 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 33 def new @user = User.new(send_credentials: true) end |
#signup ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 37 def signup if while_signup? new else flash[:warning] = _t(:cannot_signup_more_then_once) redirect_to admin_dashboard_path end end |
#update ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 56 def update # User is fetched via before filter if params[:user][:password].present? @user.update(user_params) else @user.update_without_password(user_params) end render_errors_or_redirect @user, admin_users_path, _t("User updated", :name => @user.name) end |