Commit 51d1709a by nnnghia98

edit model users and jobs

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