Commit 60fdeba5 by Thanh Hung Pham

Scope search date

parent b94c4478
......@@ -7,9 +7,9 @@ class AdminsController < ApplicationController
@city_id = params[:city_id] if params[:city_id].present?
@category_id = params[:category_id] if params[:category_id].present?
@from_date_default = Date.new(params[:from_date]['(1i)'].to_i, params[:from_date]['(2i)'].to_i, params[:from_date]['(3i)'].to_i)
@to_date_default = Date.new(params[:to_date]['(1i)'].to_i, params[:to_date]['(2i)'].to_i, params[:to_date]['(3i)'].to_i)
@from_date_default = Date.new(params[:from_date]['(1i)'].to_i, params[:from_date]['(2i)'].to_i, params[:from_date]['(3i)'].to_i) if params[:from_date].present?
@to_date_default = Date.new(params[:to_date]['(1i)'].to_i, params[:to_date]['(2i)'].to_i, params[:to_date]['(3i)'].to_i) if params[:to_date].present?
@applied_jobs = Apply.all.page params[:page]
@applied_jobs = Apply.applied_at_between(@from_date_default, @to_date_default).page params[:page]
end
end
......@@ -3,4 +3,6 @@ class Apply < ApplicationRecord
belongs_to :job
paginates_per 20
scope :applied_at_between, ->(from_date, to_date) { where('applied_at >= ? AND applied_at <= ?', from_date, to_date) }
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment