Commit 5e04a98f by thanhnd

job detail and history jobs

parent 0ebcc9ac
Pipeline #605 failed with stages
in 0 seconds
class JobsController < ApplicationController
def show
@job_detail = Job.find_by_id(params[:id])
HistoryJob.find_or_create_by(job_id: @job_detail.id, user_id: current_user)
if current_user
HistoryJob.find_or_create_by(job_id: @job_detail.id, user_id: current_user.id)
end
end
def history
@historyjobs = HistoryJob.job_by_id(current_user.id)
@hj = []
@historyjobs.each do |historyjob|
@hj << Job.find(historyjob.job_id)
end
end
def index
......
class HistoryJob < ApplicationRecord
belongs_to :job
belongs_to :user
def self.job_by_id(user_id)
select('job_id').where(user_id: user_id)
end
end
\ No newline at end of file
class Job < ApplicationRecord
has_many :industry_jobs
has_many :saved_jobs
has_many :history_jobs
has_many :applied_jobs
has_and_belongs_to_many :users
belongs_to :area
......
......@@ -3,7 +3,7 @@
<% @pagin_job.each do |job| %>
<ul>
<button class="button2">Favorites</button>
<li><%= job['job_name'] %></li>
<li><%= link_to job['job_name'], job_detail_url(job['id']) %></li>
</ul>
<% end %>
\ No newline at end of file
<div id="search" class="container p-5 my-2 bg-secondary text-white">
<!-- Search form -->
<form class="form-inline md-form mr-auto mb-4">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-warning btn-rounded btn-sm my-0" type="submit">Search</button>
</form>
</div>
<div id="job_hisotry"class="container p-5 my-2 bg-secondary text-white">
<% if @historyjobs.nil? == true %>
<div> This id is not available. </div>
<% else %>
<font color="red"><b><label > Job History:</label></b></font>
<ul>
<% @hj.each do |j| %>
<li><%= link_to j.job_name, job_detail_url(j.id) %></li>
<li><%= j.salary %></li>
<li><%= j.level %></li>
<li><%= j.experience %></li>
<li ><span class="text"><%= j.description %></span>
</li>
<br>
<% end %>
</ul>
<button class="button button1">Apply</button>
<button class="button button2">Favorites</button>
<% end %>
</div>
......@@ -45,7 +45,7 @@
</li>
<li class="nav-item">
<a class="nav-link" href="#"><li><%= link_to 'History'%></li></a>
<a class="nav-link" href="#"><li><%= link_to 'History', history_url %></li></a>
</li>
</ul>
</div>
......
......@@ -10,7 +10,8 @@ Rails.application.routes.draw do
delete "signout" => "devise/sessions#destroy"
end
get 'detail/:id', to: 'jobs#show'
get 'detail/:id', to: 'jobs#show', as: :job_detail
get 'history', to: 'jobs#history'
get 'jobs/search' => 'jobs#search', as: :job_search
root 'top_page#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
......
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