How do I handle authentication with Devise when using multiple models in Rails 3.2 App

前端 未结 3 2045
你的背包
你的背包 2021-02-14 05:16

I\'m working on a Rails 3.2 app where I use Devise for authentication. I decided to try single table inheritance for managing user roles, but I quickly ran into a problem. I cur

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 05:49

    You can solve this using the following solution

    def authenticate!
        if modelA_user_signed_in?
          @current_user = current_modelA
          true
        else
          authenticate_modelB!
        end
    
      end
    

提交回复
热议问题