Commit 81a7e69f by Quang Vinh Nguyen

fix entries dependent job destroy

parent f87141f5
......@@ -27,11 +27,11 @@ class EntriesController < ApplicationController
@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])
else
@user = User.new( name: params[:entry][:entry_name],
unless @user
random_password = Devise.friendly_token
@user = User.new(name: params[:entry][:entry_name],
email: params[:entry][:entry_email],
phone: params[:entry][:entry_phone],
address: params[:entry][:entry_address],
......
......@@ -11,11 +11,9 @@ class Job < ApplicationRecord
dependent: :destroy
has_many :industries, through: :industries_jobs
has_many :entries, foreign_key: 'job_id',
dependent: :destroy
has_many :entries, foreign_key: 'job_id'
has_many :users, through: :entries
validates :title, presence: true, length: { maximum: 255 },
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