foodsoft/app/controllers/admin/ordergroups_controller.rb

26 lines
827 B
Ruby
Raw Permalink Normal View History

class Admin::OrdergroupsController < Admin::BaseController
2011-06-10 01:36:04 +02:00
inherit_resources
2018-12-21 01:12:43 +01:00
def index
@ordergroups = Ordergroup.undeleted.sort_by_param(params['sort'])
2011-06-10 01:36:04 +02:00
2018-12-21 01:12:43 +01:00
if request.format.csv?
send_data OrdergroupsCsv.new(@ordergroups).to_csv, filename: 'ordergroups.csv',
type: 'text/csv'
2018-12-21 01:12:43 +01:00
end
2011-06-10 01:36:04 +02:00
# if somebody uses the search field:
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:query]}%") if params[:query].present?
2011-06-10 01:36:04 +02:00
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
end
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
end