Class: Foodcoop::UsersController

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

Instance Method Summary collapse

Instance Method Details

#indexObject


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/foodcoop/users_controller.rb', line 3

def index
  @users = User.undeleted.natural_order

  # if somebody uses the search field:
  @users = @users.natural_search(params[:user_name]) unless params[:user_name].blank?

  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)

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