Class: Admin::WorkgroupsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/workgroups_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



12
13
14
15
16
17
18
# File 'app/controllers/admin/workgroups_controller.rb', line 12

def destroy
  @workgroup = Workgroup.find(params[:id])
  @workgroup.destroy
  redirect_to admin_workgroups_url, notice: t('.notice')
rescue StandardError => e
  redirect_to admin_workgroups_url, alert: t('.error', error: e.message)
end

#indexObject



4
5
6
7
8
9
10
# File 'app/controllers/admin/workgroups_controller.rb', line 4

def index
  @workgroups = Workgroup.order('name ASC')
  # if somebody uses the search field:
  @workgroups = @workgroups.where('name LIKE ?', "%#{params[:query]}%") if params[:query].present?

  @workgroups = @workgroups.page(params[:page]).per(@per_page)
end