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
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 35 def create @user = User.new(user_params) if while_signup? signup_admin_or_redirect else create_user_or_redirect end end |
#destroy ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 58 def destroy # User is fetched via before filter name = @user.name if @user.destroy flash[:notice] = Alchemy.t("User deleted", name: name) end do_redirect_to admin_users_path end |
#index ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 14 def index @query = User.ransack(params[:q]) @query.sorts = "login asc" if @query.sorts.empty? @users = @query.result .page(params[:page] || 1) .per(items_per_page) end |
#new ⇒ Object
22 23 24 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 22 def new @user = User.new(send_credentials: true) end |
#signup ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 26 def signup if while_signup? new else flash[:warning] = Alchemy.t(:cannot_signup_more_then_once) redirect_to admin_dashboard_path end end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/alchemy/admin/users_controller.rb', line 45 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 deliver_welcome_mail render_errors_or_redirect @user, admin_users_path, Alchemy.t("User updated", name: @user.name) end |