Class: RubyCms::Admin::UsersController

Inherits:
BaseController show all
Includes:
RubyCms::AdminPagination, RubyCms::AdminTurboTable
Defined in:
app/controllers/ruby_cms/admin/users_controller.rb

Constant Summary

Constants included from RubyCms::AdminPagination

RubyCms::AdminPagination::DEFAULT_MAX_PER_PAGE, RubyCms::AdminPagination::DEFAULT_MIN_PER_PAGE

Instance Method Summary collapse

Methods included from RubyCms::AdminTurboTable

#turbo_frame_id, #turbo_frame_request?, #turbo_redirect_to, #turbo_render_index, #turbo_stream_replace_table, #turbo_stream_request?, #turbo_stream_update_table

Methods included from RubyCms::AdminPagination

#paginate_collection, #set_pagination_vars

Instance Method Details

#bulk_deleteObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/ruby_cms/admin/users_controller.rb', line 34

def bulk_delete
  ids = Array(params[:item_ids]).filter_map(&:to_i)
  users = user_class.where(id: ids)
  count = users.count
  users.destroy_all
  turbo_redirect_to ruby_cms_admin_users_path, notice: "#{count} user(s) #{
    t('ruby_cms.admin.users.deleted')
  }."
end

#createObject



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

def create
  user = user_class.new(user_params)
  if user.save
    redirect_to ruby_cms_admin_users_path, notice: t("ruby_cms.admin.users.created")
  else
    handle_create_failure(user)
  end
end

#destroyObject



28
29
30
31
32
# File 'app/controllers/ruby_cms/admin/users_controller.rb', line 28

def destroy
  user = user_class.find(params[:id])
  user.destroy
  redirect_to ruby_cms_admin_users_path, notice: t("ruby_cms.admin.users.deleted")
end

#indexObject



14
15
16
17
# File 'app/controllers/ruby_cms/admin/users_controller.rb', line 14

def index
  @users = paginated_users
  @index ||= user_class.none
end