Class: Integral::Backend::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/integral/backend/users_controller.rb

Overview

Users controller

Instance Method Summary collapse

Instance Method Details

#accountObject

GET /account Show specific users account page



38
39
40
41
42
43
# File 'app/controllers/integral/backend/users_controller.rb', line 38

def 
  @user = current_user
  add_breadcrumb @user.name, :backend_account_path

  render :show
end

#createObject

POST / User creation



47
48
49
50
51
52
53
54
55
# File 'app/controllers/integral/backend/users_controller.rb', line 47

def create
  @user = User.invite!(user_params, current_user)

  if @user.errors.present?
    respond_failure I18n.t('integral.backend.users.notification.creation_failure'), 'new'
  else
    respond_successfully I18n.t('integral.backend.users.notification.creation_success'), backend_user_path(@user)
  end
end

#destroyObject

DELETE /:id



78
79
80
81
82
# File 'app/controllers/integral/backend/users_controller.rb', line 78

def destroy
  @user.destroy

  respond_successfully I18n.t('integral.backend.users.notification.delete_success'), backend_users_path
end

#editObject

GET /:id/edit User edit form



59
60
61
62
# File 'app/controllers/integral/backend/users_controller.rb', line 59

def edit
  add_breadcrumb @user.name, :backend_user_path
  add_breadcrumb I18n.t('integral.navigation.edit'), :edit_backend_user_path
end

#indexObject

GET / Lists all users



12
13
14
15
16
17
18
19
# File 'app/controllers/integral/backend/users_controller.rb', line 12

def index
  respond_to do |format|
    format.html
    format.json do
      render json: { content: render_to_string(partial: 'integral/backend/users/grid', locals: { grid: @grid }) }
    end
  end
end

#newObject

GET /new User creation form



23
24
25
26
# File 'app/controllers/integral/backend/users_controller.rb', line 23

def new
  add_breadcrumb I18n.t('integral.navigation.new'), :new_backend_user_path
  @user = User.new
end

#showObject

GET /:id Show specific user



31
32
33
# File 'app/controllers/integral/backend/users_controller.rb', line 31

def show
  add_breadcrumb @user.name, :backend_user_path
end

#updateObject

PUT /:id Updating a user



66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/integral/backend/users_controller.rb', line 66

def update
  authorized_user_params = user_params
  authorized_user_params.delete(:role_ids) unless policy(@user).manager?

  if @user.update(authorized_user_params)
    respond_successfully I18n.t('integral.backend.users.notification.edit_success'), backend_user_path(@user)
  else
    respond_failure I18n.t('integral.backend.users.notification.edit_failure'), 'edit'
  end
end