Class: Foodcoop::OrdergroupsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foodcoop/ordergroups_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



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

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

  @ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:name]}%") if params[:name].present? # Search by name

  @ordergroups = @ordergroups.active if params[:only_active] # Select only active groups

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

  respond_to do |format|
    format.html # index.html.erb
    format.js { render layout: false }
  end
end