Skip to content

Instantly share code, notes, and snippets.

@ckk-scratch
Created December 5, 2016 19:41
Show Gist options
  • Save ckk-scratch/03e19c2d8a1516e43da87999b4b308c1 to your computer and use it in GitHub Desktop.
Save ckk-scratch/03e19c2d8a1516e43da87999b4b308c1 to your computer and use it in GitHub Desktop.
class TalentController < ApplicationController
authorize_resource
def index
@regions = Region.where(type: Region.name).order(:state,:name)
@region_id = params[:region_id]
@status = params[:status]
region = Region.find(@region_id) unless @region_id.blank?
page = params[:page].nil? ? 1 : params[:page].to_i
if @status.blank?
relation = region.nil? ? Talent.all : region.talent
else
relation = region.nil? ? Talent.all.where(status: @status.downcase) : region.talent.where(status: @status.downcase)
end
@q = relation.search(params[:q])
@records = @q.result.paginate(page: page)
end
def sync
Talent.sync_with_filemaker
redirect_to 'index'
end
def show
@talent = Talent.find(params[:id])
end
# ....
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment