require_dependency "educode_sales/application_controller" module EducodeSales class UserBehaviorsController < ApplicationController def index respond_to do |format| format.html do end format.json do if params[:sort].present? && params[:sort][:field] if params[:sort][:field] == 'name' @data = LoginHistory.joins(staff: :user).order("users.lastname #{params[:sort][:order]}") else @data = LoginHistory.order("#{params[:sort][:field]} #{params[:sort][:order]}") end else @data = LoginHistory.order(created_at: :desc) end @data = @data.page(params[:page]).per(params[:limit]) end end end end end