Class: Spina::Admin::UsersController

Inherits:
AdminController show all
Defined in:
app/controllers/spina/admin/users_controller.rb

Instance Method Summary collapse

Methods inherited from AdminController

#current_admin_path

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spina/admin/users_controller.rb', line 17

def create
  @user = User.new(user_params)
  add_breadcrumb I18n.t('spina.users.new')
  if @user.save
    redirect_to admin_users_url
  else
    flash.now[:alert] = I18n.t('spina.users.cannot_be_created')
    render :new
  end
end

#destroyObject



42
43
44
45
# File 'app/controllers/spina/admin/users_controller.rb', line 42

def destroy        
  @user.destroy unless @user == current_spina_user
  redirect_to admin_users_url
end

#editObject



28
29
30
# File 'app/controllers/spina/admin/users_controller.rb', line 28

def edit        
  add_breadcrumb "#{@user}"
end

#indexObject



8
9
10
# File 'app/controllers/spina/admin/users_controller.rb', line 8

def index
  @users = User.all
end

#newObject



12
13
14
15
# File 'app/controllers/spina/admin/users_controller.rb', line 12

def new
  @user = User.new
  add_breadcrumb I18n.t('spina.users.new')
end

#updateObject



32
33
34
35
36
37
38
39
40
# File 'app/controllers/spina/admin/users_controller.rb', line 32

def update        
  add_breadcrumb "#{@user}"
  if @user.update(user_params)
    redirect_to spina.admin_users_url
  else
    flash.now[:alert] = I18n.t('spina.users.cannot_be_created')
    render :edit
  end
end