Class: Admin::OrdergroupsController

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

Instance Method Summary collapse

Instance Method Details

#destroyObject



18
19
20
21
22
23
24
# File 'app/controllers/admin/ordergroups_controller.rb', line 18

def destroy
  @ordergroup = Ordergroup.find(params[:id])
  @ordergroup.mark_as_deleted
  redirect_to admin_ordergroups_url, notice: t('.notice')
rescue StandardError => e
  redirect_to admin_ordergroups_url, alert: t('.error')
end

#indexObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/admin/ordergroups_controller.rb', line 4

def index
  @ordergroups = Ordergroup.undeleted.sort_by_param(params['sort'])

  if request.format.csv?
    send_data OrdergroupsCsv.new(@ordergroups).to_csv, filename: 'ordergroups.csv',
                                                       type: 'text/csv'
  end

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

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