Refactored items_per_page. Start on admin/workgroups.
This commit is contained in:
parent
689cfcfe01
commit
6ddef7267a
13 changed files with 35 additions and 119 deletions
|
|
@ -1,12 +1,6 @@
|
|||
class Foodcoop::OrdergroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
|
||||
@per_page = params[:per_page].to_i
|
||||
else
|
||||
@per_page = 20
|
||||
end
|
||||
|
||||
@ordergroups = Ordergroup.order(:name.desc)
|
||||
@ordergroups = @ordergroups.where(:name.matches => "%#{params[:query]}%") unless params[:query].blank? # Search by name
|
||||
@ordergroups = @ordergroups.joins(:orders).where(:orders => {:starts.gte => Time.now.months_ago(3)}) if params[:only_active] # Select only active groups
|
||||
|
|
|
|||
|
|
@ -8,13 +8,6 @@ class Foodcoop::UsersController < ApplicationController
|
|||
@users = @users.where(({:first_name.matches => "%#{params[:query]}%"}) | ({:last_name.matches => "%#{params[:query]}%"}) | ({:nick.matches => "%#{params[:query]}%"}))
|
||||
end
|
||||
|
||||
# sort by nick, thats default
|
||||
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
|
||||
@per_page = params[:per_page].to_i
|
||||
else
|
||||
@per_page = 20
|
||||
end
|
||||
|
||||
@users = @users.paginate(:page => params[:page], :per_page => @per_page)
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue