Commit d7f5a870 by nnnghia98

using before_action find_user

parent 9c4f8916
class JobsController < ApplicationController
before_action :authenticate_user!, only: [:apply, :confirm_apply, :finish_apply]
before_action :find_user, only: :apply_available
def index
if params[:city_id]
......@@ -41,9 +42,17 @@ class JobsController < ApplicationController
end
end
def apply_available
user_jobs.find_by(job_id: @job_id, user_id: @user.id)
end
private
def confirm_apply_info_params
params.require(:confirm_apply_info).permit(:job_id, :first_name, :last_name, :email)
end
def find_user
@user = User.fint_by(:id)
end
end
......@@ -43,9 +43,4 @@ class Job < ApplicationRecord
def self.latest_job
@latest_job ||= order(updated_at: :desc).take(Settings.top.job.limit)
end
def apply_available
user = User.find_by(:id)
user_jobs.find_by(job_id: @job_id, user_id: user.id)
end
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