Search code examples
ruby-on-railsdeviseruby-on-rails-5omniauth

how to deal with multiple devise model for omniauth in ruby on rails


I have a 3types of users (student, teacher and admin). Students will record their study, Teachers will supervise students and admins will administer service. So I made all users with a devise gem. Actually my purpose was that every user can login with facebook or twitter but I couldn't do that because omniauthable in devise supports only one devise model... how to deal with multiple devise model for omniauth like

<%= link_to 'student login with facebook', ........ %>
<%= link_to 'teacher login with facebook', ........ %>

Solution

  • You can follow this Devise guide on how to get around setting up multiple models with Devise :omniauthable here.

    If you can get around using multiple models you should consider using 1 User model with 3 roles (Student, Teacher, Admin). Check out the cancancan gem and that might fit in better what with you are looking to do.