Class: Fae::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Fae::UsersController
- Defined in:
- app/controllers/fae/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #settings ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/fae/users_controller.rb', line 25 def create @user = Fae::User.new(user_params) if @user.save redirect_to users_path, notice: t('fae.save_notice') else render action: 'new', error: t('fae.save_error') end end |
#destroy ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/controllers/fae/users_controller.rb', line 51 def destroy @user.destroy respond_to do |format| format.html { redirect_to users_url } format.json { head :no_content } end end |
#edit ⇒ Object
16 17 |
# File 'app/controllers/fae/users_controller.rb', line 16 def edit end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/fae/users_controller.rb', line 8 def index @users = current_user.super_admin? ? Fae::User.all : Fae::User.public_users end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/fae/users_controller.rb', line 12 def new @user = Fae::User.new end |
#settings ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/fae/users_controller.rb', line 19 def settings @user = current_user # set index path to dashboard @index_path = root_path end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/fae/users_controller.rb', line 37 def update params[:user].delete(:password) if params[:user][:password].blank? params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank? if @user.update(user_params) path = current_user.super_admin_or_admin? ? users_path : fae.root_path redirect_to path, notice: t('fae.save_notice') else render action: 'edit', error: t('fae.save_error') end end |