Commit 51d1709a by nnnghia98

edit model users and jobs

parent c24a7643
......@@ -28,16 +28,14 @@ class JobsController < ApplicationController
end
def finish_apply
@apply_first_name = params["confirm_apply_info"]["first_name"]
@apply_last_name = params["confirm_apply_info"]["last_name"]
@apply_email = params["confirm_apply_info"]["email"]
@job_id = params["confirm_apply_info"]["job_id"]
@apply_info = params[:confirm_apply_info]
@job_id = params[:confirm_apply_info][:job_id]
if params[:commit] == "Edit"
render "jobs/apply"
redirect_to apply_path(job_id: @job_id)
else
UserJob.find_by(user_id: current_user.id, job_id: @job_id) ||
UserJob.create!(user_id: current_user.id, job_id: @job_id, applied_at: Time.current)
current_user.user_jobs.find_by(user_id: current_user.id, job_id: @job_id) ||
current_user.user_jobs.create!(user_id: current_user.id, job_id: @job_id, applied_at: Time.current)
end
end
end
......@@ -37,6 +37,9 @@ class Job < ApplicationRecord
has_many :industry_jobs
has_many :industries, through: :industry_jobs
has_many :user_jobs
has_many :users, through: :user_jobs
def self.latest_job
@latest_job ||= order(updated_at: :desc).take(Settings.top.job.limit)
end
......
......@@ -28,6 +28,9 @@
#
class User < ApplicationRecord
has_many :user_jobs
has_many :jobs, through: :user_jobs
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
......
......@@ -8,21 +8,21 @@
<h3>Confirmation</h3>
<%= form_for "confirm_apply_info", url: done_path, method: :post do |f| %>
<%= f.hidden_field :job_id, value: params["apply_info"]["job_id"] %>
<%= f.hidden_field :first_name, value: params["apply_info"]["first_name"] %>
<%= f.hidden_field :last_name, value: params["apply_info"]["last_name"] %>
<%= f.hidden_field :email, value: params["apply_info"]["email"] %>
<%= f.hidden_field :job_id, value: params[:apply_info][:job_id] %>
<%= f.hidden_field :first_name, value: params[:apply_info][:first_name] %>
<%= f.hidden_field :last_name, value: params[:apply_info][:last_name] %>
<%= f.hidden_field :email, value: params[:apply_info][:email] %>
<div class="form-group">
First name: <%= f.label :first_name, params["apply_info"]["first_name"] %>
First name: <%= f.label :first_name, params[:apply_info][:first_name] %>
</div>
<div class="form-group">
Last name: <%= f.label :last_name, params["apply_info"]["last_name"] %>
Last name: <%= f.label :last_name, params[:apply_info][:last_name] %>
</div>
<div class="form-group">
Email: <%= f.label :email, params["apply_info"]["email"] %>
Email: <%= f.label :email, params[:apply_info][:email] %>
</div>
<div class="actions text-center">
......
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