Sha256: 1425a3d5b2cee4b9cb27f553878337b9bf73f7da625be7c2aefa682e84c0bae2

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module Users
  
  # ---------------------------------------------------------------------------
  # Paginate top users
  get "/users/:page" do
    page = params[:page] ? params[:page].to_i : 1

    @users       = Wackamole::User.paginate_tops( @filter.to_conds, page )   
    @search_path = "/users/search"
    @filter_path = "/users/filter"
   
    if request.xhr?
      erb :'users/index.js', :layout => false
    else
      erb :'users/index'
    end
  end
  
  # ---------------------------------------------------------------------------
  # search users
  post "/users/search" do
    begin
      @filter.search_terms = params[:search_filter][:search_terms]      
      @users = Wackamole::User.paginate_tops( @filter.to_conds )
    rescue => boom
      logger.error boom
      flash[:error] = boom
      @users = [].paginate
    end

    erb :"users/filter.js", :layout => false
  end
    
  # ---------------------------------------------------------------------------
  # Filter
  post "/users/filter" do    
    @filter.from_options( params[:filter] )
    @users = Wackamole::User.paginate_tops( @filter.to_conds )
    erb :"users/filter.js", :layout => false
  end  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wackamole-0.0.3 lib/controllers/users.rb
wackamole-0.0.2 lib/controllers/users.rb
wackamole-0.0.1 lib/controllers/users.rb