Commit e0740f33 by Ngô Trung Hưng

use render collection & fix method add_job_to_history

parent 57a0d779
Pipeline #992 failed with stages
in 0 seconds
......@@ -1622,3 +1622,6 @@ $main-color: #23303D;
height: 100%;
z-index: 99999;
}
#label_name_file {
cursor: pointer;
}
\ No newline at end of file
......@@ -3,12 +3,12 @@
# Job controller
class JobController < ApplicationController
before_action :load_data_dropdown, only: :index
after_action :add_job_to_history, only: :detail
def add_job_to_history
current_user.histories.find_or_create_by(job_id: session[:params_job_id]) if user_signed_in?
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 > 20
session.delete(:params_job_id)
current_user.histories.destroy(current_user.histories.first) if counter_history > History::NUMBER_JOB_LIMIT
end
def index
......@@ -19,7 +19,9 @@ class JobController < ApplicationController
def detail
@job = Job.find(params[:id]).decorate
session[:params_job_id] = @job.id
return render 'error/fage_not_found' if @job.blank?
add_job_to_history(@job.id)
cities = @job.cities.first
industries = @job.industries.first
add_breadcrumb t('controller.job.detail.home'), root_path
......
......@@ -2,6 +2,7 @@
# Description/Explanation of Person class
class History < ApplicationRecord
NUMBER_JOB_LIMIT = 20
belongs_to :user
belongs_to :job
end
......@@ -14,7 +14,7 @@
<div class="col-lg-12">
<div class="breadcrumb_total_search">
<span class="breadcrumb-item active">
<%= t('favorite.list_blank') %>
<%= t('favorite.empty') %>
</span>
</div>
</div>
......
......@@ -14,25 +14,23 @@
<div class="col-lg-12">
<div class="breadcrumb_total_search">
<span class="breadcrumb-item active">
<%= t('history.list_blank') %>
<%= t('history.empty') %>
</span>
</div>
</div>
<div style="width: 100%; height: 55vh"></div>
<% else %>
<%= form_with url: apply_path, method: :get, local: true, skip_enforcing_utf8: true do |f| %>
<div class="container">
<div class="box_scroll">
<% @jobs.each do |item| %>
<%= render 'histories/block_job_mini', data: item, form: f %>
<% end %>
<%= form_with url: apply_path, method: :get, local: true, skip_enforcing_utf8: true do |f| %>
<div class="container">
<div class="box_scroll">
<%= render partial: 'histories/block_job_mini', collection: @jobs, as: :data, locals: { form: f } %>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="btn_apply_job in_favorite">
<%= f.submit t('pages.detail.btr_text_submit_cv'), name: nil, class: 'btn btn-apply_job in_favorite' %>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="btn_apply_job in_favorite">
<%= f.submit t('pages.detail.btr_text_submit_cv'), name: nil, class: 'btn btn-apply_job in_favorite' %>
</div>
</div>
</div>
......
......@@ -136,11 +136,11 @@ en:
favorite:
liked: 'You have added job to favorites'
list: 'List of jobs you liked'
list_blank: 'You do not have a favorite job!'
empty: 'You do not have a favorite job!'
history:
list: 'Histories'
list_blank: 'You do not have a histories'
see: 'See: '
empty: 'You do not have a histories'
seen_at: 'Seen_at: '
activerecord:
attributes:
applied_job:
......
......@@ -136,11 +136,11 @@ vi:
favorite:
liked: 'Bạn đã thêm công việc vào yêu thích.'
list: 'Danh sách công việc bạn đã thích'
list_blank: 'Bạn chưa công việc yêu thích!'
empty: 'Bạn chưa công việc yêu thích!'
history:
list: 'Lịch sử'
list_blank: 'Bạn chưa xem công việc nào luôn á!'
see: 'Đã xem lúc: '
empty: 'Bạn chưa xem công việc nào luôn á!'
seen_at: 'Đã xem lúc: '
activerecord:
attributes:
applied_job:
......
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