Class: Spina::Admin::UsersController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- AdminController
- Spina::Admin::UsersController
- Defined in:
- app/controllers/spina/admin/users_controller.rb
Instance Method Summary collapse
Methods inherited from AdminController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/spina/admin/users_controller.rb', line 21 def create @user = User.new(user_params) if @user.save redirect_to admin_users_url else flash.now[:alert] = I18n.t("spina.users.cannot_be_created") I18n.t("spina.users.new") render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
50 51 52 53 54 55 |
# File 'app/controllers/spina/admin/users_controller.rb', line 50 def destroy if @user != current_spina_user @user.destroy redirect_to spina.admin_users_url, flash: {success: t("spina.users.deleted")} end end |
#edit ⇒ Object
33 34 35 36 |
# File 'app/controllers/spina/admin/users_controller.rb', line 33 def edit @user.to_s end |
#index ⇒ Object
10 11 12 13 |
# File 'app/controllers/spina/admin/users_controller.rb', line 10 def index @users = User.order(:name) I18n.t("spina.preferences.users"), spina.admin_users_path end |
#new ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/spina/admin/users_controller.rb', line 15 def new @user = User.new I18n.t("spina.users.new") end |
#update ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/spina/admin/users_controller.rb', line 38 def update if @user.update(user_params) flash[:success] = t("spina.users.saved") redirect_to spina.admin_users_url else flash.now[:alert] = I18n.t("spina.users.cannot_be_created") @user.to_s render :edit, status: :unprocessable_entity end end |