Sha256: 9f4fa6d4dc0e1f2ded1ecceb47ec97a177e5297ac81385c8ca142293fe5fc60c

Contents?: true

Size: 875 Bytes

Versions: 5

Compression:

Stored size: 875 Bytes

Contents

require_dependency "customer_vault/application_controller"
require 'handles_sortable_columns'

module CustomerVault
  class PeopleController < ApplicationController
    handles_sortable_columns
    before_action :set_individual, only: [:show, :edit, :update, :destroy]
    
    def index
      people = sortable_column_order do |column, direction|
        case column
        when 'name'
          (direction == :asc) ? Person.list.sort_by(&:name)
                              : Person.list.sort_by(&:name).reverse
        when 'zip'
          (direction == :asc) ? Person.list.sort{|a,b| a.address.zip <=> b.address.zip}
                              : Person.list.sort{|a,b| b.address.zip <=> a.address.zip}
        else
          Person.list.sort_by(&:name)
        end
      end
      @people= Kaminari.paginate_array(people).page(params[:page]).per(8)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
customer_vault-1.1.0 app/controllers/customer_vault/people_controller.rb
customer_vault-1.0.4 app/controllers/customer_vault/people_controller.rb
customer_vault-1.0.3 app/controllers/customer_vault/people_controller.rb
customer_vault-1.0.2 app/controllers/customer_vault/people_controller.rb
customer_vault-1.0.1 app/controllers/customer_vault/people_controller.rb