Commit f87141f5 by Quang Vinh Nguyen

add random password

parent 13c666b9
...@@ -27,13 +27,19 @@ class EntriesController < ApplicationController ...@@ -27,13 +27,19 @@ class EntriesController < ApplicationController
@job = Job.find(params[:job_id]) @job = Job.find(params[:job_id])
@user = User.find_by(email: params[:entry][:entry_email]) || random_password = Devise.friendly_token
User.create( name: params[:entry][:entry_name],
if @user = User.find_by(email: params[:entry][:entry_email])
else
@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],
# password: 'password', password: random_password,
# password_confirmation: 'password') password_confirmation: random_password)
@user.skip_confirmation!
@user.save!
end
@entry.user_id = @user.id @entry.user_id = @user.id
@entry.job_id = @job.id @entry.job_id = @job.id
......
...@@ -4,8 +4,8 @@ class User < ApplicationRecord ...@@ -4,8 +4,8 @@ class User < ApplicationRecord
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable # :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable#, :recoverable, :rememberable, :validatable,
# :confirmable :confirmable
has_many :favorite_jobs, dependent: :destroy has_many :favorite_jobs, dependent: :destroy
...@@ -13,7 +13,7 @@ class User < ApplicationRecord ...@@ -13,7 +13,7 @@ class User < ApplicationRecord
dependent: :destroy dependent: :destroy
has_many :jobs, through: :entries has_many :jobs, through: :entries
validates :name, presence: true, length: { maximum: 255 } # validates :name, presence: true, length: { maximum: 255 }
# validates :prefix, presence: true # validates :prefix, presence: true
...@@ -27,8 +27,9 @@ class User < ApplicationRecord ...@@ -27,8 +27,9 @@ class User < ApplicationRecord
validates :password, presence: true, length: { minimum: 8 } validates :password, presence: true, length: { minimum: 8 }
# Sends activation email. # Sends apply email.
def send_job_apply_email(job) def send_job_apply_email(job)
UserMailer.job_apply(self, job).deliver_now UserMailer.job_apply(self, job).deliver_now
end end
end end
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