Commit 81a7e69f by Quang Vinh Nguyen

fix entries dependent job destroy

parent f87141f5
...@@ -27,11 +27,11 @@ class EntriesController < ApplicationController ...@@ -27,11 +27,11 @@ class EntriesController < ApplicationController
@job = Job.find(params[:job_id]) @job = Job.find(params[:job_id])
random_password = Devise.friendly_token @user = User.find_by(email: params[:entry][:entry_email])
if @user = User.find_by(email: params[:entry][:entry_email]) unless @user
else random_password = Devise.friendly_token
@user = User.new( name: params[:entry][:entry_name], @user = User.new(name: params[:entry][:entry_name],
email: params[:entry][:entry_email], email: params[:entry][:entry_email],
phone: params[:entry][:entry_phone], phone: params[:entry][:entry_phone],
address: params[:entry][:entry_address], address: params[:entry][:entry_address],
......
...@@ -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