Using Devise gem :-
in my application i have two type user 1) Company 2) Employee
i have two separate model for both user and i want to give single sign-in page for both user
i already generate different views for both user using devise but then also i need single sign-in.
so how it is possible please help me out...!!!!!!!!!
i try this:- controllers/compnaies/sessions_controller.rb
def create
@employee = Employee.new
@company = Company.new
if @company.email_exist?(params[:company][:email])
super
elsif @employee.email_exist?(params[:company][:email])
params[:employee]=params[:company]
redirect_to employee_session_path(params)
end
end
employee_session_path is the path of employees's sessions create method but it always call new method of employees's sessions
controllers/employees/sessions_controller.rb
def create
super
end
email_exist? method check the email id in both model which is provided by any of user
in my model:
company.rb
def email_exist?(email)
if Company.find_by(email: email)
return true
end
end
employee.rb
def email_exist?(email)
if Employee.find_by(email: email)
return true
end
end
Thanks in advance...!!!!!!!!
Aucun commentaire:
Enregistrer un commentaire