foodsoft/app/controllers/foodcoop/ordergroups_controller.rb

22 lines
635 B
Ruby
Raw Normal View History

class Foodcoop::OrdergroupsController < ApplicationController
def index
@ordergroups = Ordergroup.undeleted.order('name DESC')
unless params[:name].blank? # Search by name
@ordergroups = @ordergroups.where('name LIKE ?', "%#{params[:name]}%")
end
if params[:only_active] # Select only active groups
@ordergroups = @ordergroups.joins(:orders).where("orders.starts >= ?", Time.now.months_ago(3)).uniq
end
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
respond_to do |format|
format.html # index.html.erb
2011-05-18 11:47:00 +02:00
format.js { render :layout => false }
end
end
end