Commit 0d8a8c83 by Hoang Phuc

set cookie job ids when user click job detail

parent 0933eacd
Pipeline #563 failed with stages
in 0 seconds
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link application.js
\ No newline at end of file
// Place all the styles related to the history controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
class HistoryController < ApplicationController
def index
if cookies[:job_ids_history].nil?
redirect_to '/jobs'
else
arr_job_ids = cookies[:job_ids_history].split(",")
end
end
end
......@@ -16,6 +16,15 @@ class JobController < ApplicationController
end
def show
@job = Job.find(params[:id])
if cookies[:job_ids_history].nil?
cookies[:job_ids_history] = {value: @job.id, expires: Time.now + 3600}
else
arr_job_ids = cookies[:job_ids_history].split(",")
unless arr_job_ids.include?(@job.id.to_s)
arr_job_ids << @job.id.to_s
end
cookies[:job_ids_history] = {value: arr_job_ids.join(","), expires: Time.now + 3600}
end
@relate_jobs = Job.where("company_id = #{@job.company_id} and id != #{@job.id}").limit(3).order("id DESC")
end
end
......@@ -13,6 +13,7 @@
<%= javascript_include_tag "/assets/js/jquery.js" %>
<%= javascript_include_tag "/assets/js/jquery-migrate.min.js" %>
<%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3&#038;libraries=geometry%2Cplaces&#038;language=en&#038;key=AIzaSyDFtSmGkBIXtMX63-bZKn50-6p3vZ2-WHE&#038;ver=5.3.2" %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
......@@ -45,6 +46,9 @@
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99991220">
<a href="/industries">Industry</a>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99991220">
<a href="/history">History</a>
</li>
<% if current_user %>
<li class="login menu-item menu-item-type-post_type menu-item-object-page menu-item-99991213">
<%= link_to 'Sign out', destroy_user_session_path, method: :delete %>
......
......@@ -7,4 +7,5 @@ Rails.application.routes.draw do
get '/job/:id', to: 'job#show'
get '/cities/', to: 'city#index'
get '/industries/', to: 'industry#index'
get '/history/', to: 'history#index'
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