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

Methods inherited from BaseController

#activities, #activity, #destroy, #duplicate, #new

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 
  @resource = current_user
  add_breadcrumb @resource.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
  @resource = User.invite!(resource_params, current_user)

  if @resource.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(@resource)
  end
end

#editObject

GET /:id/edit Resource edit screen



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

def edit
  add_breadcrumb @resource.name, :backend_user_path
  add_breadcrumb I18n.t('integral.navigation.edit'), "edit_backend_#{controller_name.singularize}_path".to_sym
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

#showObject

GET /:id Show specific user



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

def show
  add_breadcrumb @resource.name, :backend_user_path
end

#updateObject

PUT /:id Updating a user



59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/integral/backend/users_controller.rb', line 59

def update
  authorized_user_params = resource_params
  authorized_user_params.delete(:role_ids) unless policy(current_user).manager?

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