In my application there are not only users, but also admins and superdomains. Since all three have the same attributes, I would like to use only one table with the additional attribute "role", which can be "user", "administrator" or "super_admin":
class User < ActiveRecord::Base
Now I want to do something like SuperAdmin.all to get only SuperAdmins. Using default_scope is similar to me:
class SuperAdmin < Admin default_scope where(["role = ?", "super_admin"])
Now I am adding default_scope for admin too:
class Admin < User default_scope where(["role = ?", "admin"])
Aaaand ... SuperAdmin.all returns nothing more. Why is this?
source share