Commit 81a7e69f by Quang Vinh Nguyen

fix entries dependent job destroy

parent f87141f5
...@@ -26,17 +26,17 @@ class EntriesController < ApplicationController ...@@ -26,17 +26,17 @@ class EntriesController < ApplicationController
@entry = Entry.new(entry_params) @entry = Entry.new(entry_params)
@job = Job.find(params[:job_id]) @job = Job.find(params[:job_id])
random_password = Devise.friendly_token
if @user = User.find_by(email: params[:entry][:entry_email]) @user = User.find_by(email: params[:entry][:entry_email])
else
@user = User.new( name: params[:entry][:entry_name], unless @user
email: params[:entry][:entry_email], random_password = Devise.friendly_token
phone: params[:entry][:entry_phone], @user = User.new(name: params[:entry][:entry_name],
address: params[:entry][:entry_address], email: params[:entry][:entry_email],
password: random_password, phone: params[:entry][:entry_phone],
password_confirmation: random_password) address: params[:entry][:entry_address],
password: random_password,
password_confirmation: random_password)
@user.skip_confirmation! @user.skip_confirmation!
@user.save! @user.save!
end end
......
...@@ -11,11 +11,9 @@ class Job < ApplicationRecord ...@@ -11,11 +11,9 @@ class Job < ApplicationRecord
dependent: :destroy dependent: :destroy
has_many :industries, through: :industries_jobs has_many :industries, through: :industries_jobs
has_many :entries, foreign_key: 'job_id', has_many :entries, foreign_key: 'job_id'
dependent: :destroy
has_many :users, through: :entries has_many :users, through: :entries
validates :title, presence: true, length: { maximum: 255 }, validates :title, presence: true, length: { maximum: 255 },
uniqueness: { case_sensitive: false } uniqueness: { case_sensitive: false }
......
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