2009-08-02 19:01:45 +02:00
|
|
|
class Foodcoop::UsersController < ApplicationController
|
|
|
|
|
|
|
|
def index
|
2012-09-30 21:15:55 +02:00
|
|
|
@users = User.order('nick ASC')
|
2011-05-15 23:43:23 +02:00
|
|
|
|
|
|
|
# if somebody uses the search field:
|
2012-10-08 15:24:32 +02:00
|
|
|
unless params[:user_name].blank?
|
|
|
|
@users = @users.where("first_name LIKE :user_name OR last_name LIKE :user_name OR nick LIKE :user_name",
|
|
|
|
user_name: "%#{params[:user_name]}%")
|
2011-05-15 23:43:23 +02:00
|
|
|
end
|
|
|
|
|
2012-10-08 15:24:32 +02:00
|
|
|
if params[:ordergroup_name]
|
|
|
|
@users = @users.joins(:groups).where("groups.type = 'Ordergroup' AND groups.name LIKE ?", "%#{params[:ordergroup_name]}%")
|
|
|
|
end
|
|
|
|
|
|
|
|
@users = @users.page(params[:page]).per(@per_page).order('users.nick ASC')
|
2009-08-02 19:01:45 +02:00
|
|
|
|
2011-05-15 23:43:23 +02:00
|
|
|
respond_to do |format|
|
|
|
|
format.html # index.html.haml
|
|
|
|
format.js { render :layout => false } # index.js.erb
|
2009-08-02 19:01:45 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|