Commit 4720630b by Ngô Trung Hưng

fix method add_job_to_history

parent e0740f33
Pipeline #997 canceled with stages
in 0 seconds
......@@ -3,14 +3,6 @@
# Job controller
class JobController < ApplicationController
before_action :load_data_dropdown, only: :index
def add_job_to_history(job_id)
return unless user_signed_in?
current_user.histories.find_or_create_by(job_id: job_id)
counter_history = current_user.histories.count
current_user.histories.destroy(current_user.histories.first) if counter_history > History::NUMBER_JOB_LIMIT
end
def index
model = params[:model].classify.constantize
obj = model.find_by(slug: params[:slug])
......@@ -21,7 +13,7 @@ class JobController < ApplicationController
@job = Job.find(params[:id]).decorate
return render 'error/fage_not_found' if @job.blank?
add_job_to_history(@job.id)
JobBusiness.add_job_to_history(@job.id, current_user) if user_signed_in?
cities = @job.cities.first
industries = @job.industries.first
add_breadcrumb t('controller.job.detail.home'), root_path
......
......@@ -13,9 +13,10 @@ module Venjob
config.exceptions_app = self.routes
config.autoload_paths << Rails.root.join('lib/service')
config.autoload_paths << Rails.root.join('lib/src')
config.autoload_paths << Rails.root.join('lib/business')
# i18n
config.i18n.available_locales = [:en, :vi]
config.i18n.default_locale = :en
config.i18n.default_locale = :vi
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
# Settings in config/environments/* take precedence over those specified here.
......
# frozen_string_literal: true
class JobBusiness
def self.add_job_to_history(job_id, current_user)
current_user.histories.find_or_create_by(job_id: job_id)
counter_history = current_user.histories.count
current_user.histories.destroy(current_user.histories.first) if counter_history > History::NUMBER_JOB_LIMIT
end
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