Do not worry, you are not stuck.
I think your best option is to override the Devise session controller and change the "new" and "create" methods for the session.
So, in your own "session_controller.rb" you will have something like this:
class SessionsController < Devise::SessionsController
And on your routes you will use something like (depending on what you called your custom models):
devise_for :users, :controllers => { :sessions => 'sessions' } devise_for :businesses, :controllers => { :sessions => 'sessions' }
The specified session controller is not configured at all. I do not know your code, so I can not help. But the main steps are:
- Inspect the
auth_options and resource_name variables to understand how they store data. - Add conditional logic to modify these variables if
resource not found in the Users table.
Devise is excellent, and the roles are great, but sometimes with one user model or even using STI does not make sense. I am writing a longer post on this exact issue in the near future, as I dealt with this in a recent project.
source share