Commit c7bffa9a by Xuan Trung Le

fix bugs

parent 39066c52
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_action :authenticate_user!
helper_method :clear_session_candidate helper_method :clear_session_candidate
def clear_session_candidate def clear_session_candidate
......
class AppliesController < ApplicationController class AppliesController < ApplicationController
before_action :authenticate_user!
def apply def apply
session[:job_id] = params[:job_id] if params[:job_id] session[:job_id] = params[:job_id] if params[:job_id]
if session[:candidate].present? if session[:candidate].present?
......
class FavoritesController < ApplicationController class FavoritesController < ApplicationController
before_action :authenticate_user!
def index def index
@jobs = current_user.liked_jobs.includes(:company) @jobs = current_user.liked_jobs.includes(:company)
end end
def user_like_job def user_like_job
job = Job.find(params[:job_id]) 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...' 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) redirect_back(fallback_location: root_path)
end end
......
class JobsController < ApplicationController class JobsController < ApplicationController
before_action :set_job, only: [:show] before_action :set_job, only: [:show]
skip_before_action :authenticate_user!, only: [:index, :city, :industry, :company, :show]
def index def index
@jobs = Job.top_list.includes(:company) @jobs = Job.top_list.includes(:company)
@cities = City.top_cities.includes(:country) @cities = City.top_cities.includes(:country)
......
...@@ -20,7 +20,9 @@ class User < ApplicationRecord ...@@ -20,7 +20,9 @@ class User < ApplicationRecord
validates_size_of :cv, maximum: 5.megabytes, message: 'size should be less than 5MB' validates_size_of :cv, maximum: 5.megabytes, message: 'size should be less than 5MB'
def like_job(job) def like_job(job)
return false if liked?(job)
liked_jobs << job liked_jobs << job
true
end end
def unlike_job(job) def unlike_job(job)
......
<div class="row"> <div class="row">
<div class="container"> <div class="container">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li><%= link_to "TOP", root_path, class: "btn btn-primary" %></li> <li><%= link_to "TOP", root_path %></li>
<li> <li>
<%- @job.cities.each_with_index do |city, index| -%> <%- @job.cities.each_with_index do |city, index| -%>
<%= "#{index > 0 ? ',' : ''}" %> <%= "#{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