Commit eb32d5c8 by Xuan Trung Le

fix bugs

parent de72620c
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
helper_method :clear_session_candidate
def clear_session_candidate
......
class AppliesController < ApplicationController
before_action :authenticate_user!
def apply
session[:job_id] = params[:job_id] if params[:job_id]
if session[:candidate].present?
......
class CitiesController < ApplicationController
skip_before_action :authenticate_user!
def index
@cities = City.city_list
end
......
class IndustriesController < ApplicationController
skip_before_action :authenticate_user!
def index
@industries = Industry.industry_list
end
......
class JobsController < ApplicationController
before_action :set_job, only: [:show]
skip_before_action :authenticate_user!, only: [:index, :city, :industry, :company, :show]
def index
@jobs = Job.top_list.includes(:company)
@cities = City.top_cities.includes(:country)
......
class MyPagesController < ApplicationController
before_action :authenticate_user!
def index
@user = current_user
end
def my_job
@jobs = current_user.applied_jobs.includes(:apply_jobs).includes(:company)
@jobs = current_user.my_jobs
end
def history
......
......@@ -47,6 +47,12 @@ class User < ApplicationRecord
applied_jobs.include?(job)
end
def my_jobs
Job.select(:'jobs.id', :'jobs.name', :'jobs.salary', :'jobs.description', :'apply_jobs.created_at', :'companies.location').
joins(:company, :apply_jobs).
where(apply_jobs: { user_id: self.id })
end
private
def password_required?
......
......@@ -8,7 +8,7 @@
<p><h4 class="mr0"><%= link_to job.name, job_path(job) %></h4></p>
<p><%= strip_tags(job.description)[0...250] %>...</p>
<p>
<span><strong>Location:</strong> <%= "#{job.company.location}" %></span>
<span><strong>Location:</strong> <%= "#{job.location}" %></span>
<span><strong>Salary:</strong> <%= job.salary %></span>
<span class="navbar-right"><strong>Applied at:</strong> <%= job.applied_at(current_user.id).strftime('%m/%d/%y') %></span>
</p>
......
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