I’m working on Ruby on Rails 3 application. Already, I have implemented authentication and authorization based on Devise and Cancan. In scope of this I have implemented “Member” object that can have at least 2 different roles – “User” and “Company”. Physically, I’d like to represent these roles as two derived classes from Member, such as User and Company.
Should I use single table inheritance or multiple table inheritance. In case of multiple table inheritance what plugin I should use ?
I know it is not the answer to your question but I think you should reconsider using something else than inheritance.
Inheritance is a great OO mechanism but is very often overused. Most often you can do a better job with an association and some kind of Strategy Pattern than with inheritance.
Activerecords are much more compatible with that kind of design than inheritance and it is also much more respecting the Single Responsibility Principle which means it’s easier to test in isolation.
If you want to go with the the Strategy pattern in your activerecord model, polymorphic association can be the way to go (this allows you to even have stateful strategies)