foodsoft/app/controllers/admin/workgroups_controller.rb
wvengen 7841245795 migrate to Rails 4.0 (closes foodcoops#214)
Conflicts:
	Gemfile.lock
2014-02-24 12:46:28 +01:00

20 lines
668 B
Ruby

# encoding: utf-8
class Admin::WorkgroupsController < Admin::BaseController
inherit_resources
def index
@workgroups = Workgroup.order('name ASC')
# if somebody uses the search field:
@workgroups = @workgroups.where('name LIKE ?', "%#{params[:query]}%") unless params[:query].blank?
@workgroups = @workgroups.page(params[:page]).per(@per_page)
end
def destroy
@workgroup = Workgroup.find(params[:id])
@workgroup.destroy
redirect_to admin_workgroups_url, notice: t('admin.workgroups.destroy.notice')
rescue => error
redirect_to admin_workgroups_url, alert: t('admin.workgroups.destroy.error', error: error.message)
end
end