Commit c7bffa9a by Xuan Trung Le

fix bugs

parent 39066c52
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 FavoritesController < ApplicationController
before_action :authenticate_user!
def index
@jobs = current_user.liked_jobs.includes(:company)
end
def user_like_job
job = Job.find(params[:job_id])
flash[:notice] = 'You have favorited this job already'
unless current_user.liked?(job)
current_user.like_job(job)
flash[:notice] = 'Successfully favorited...'
end
flash[:notice] = 'You have favorited this job already' unless current_user.like_job(job)
redirect_back(fallback_location: root_path)
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)
......
......@@ -20,7 +20,9 @@ class User < ApplicationRecord
validates_size_of :cv, maximum: 5.megabytes, message: 'size should be less than 5MB'
def like_job(job)
return false if liked?(job)
liked_jobs << job
true
end
def unlike_job(job)
......
<div class="row">
<div class="container">
<ol class="breadcrumb">
<li><%= link_to "TOP", root_path, class: "btn btn-primary" %></li>
<li><%= link_to "TOP", root_path %></li>
<li>
<%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %>
......
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