Class: Foodcoop::UsersController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



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

def index
  @users = User.undeleted.sort_by_param(params['sort'])

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

  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