Ruby multiple inheritance needed for rails models -


first off, let me know multiple inheritance not possible in ruby, when think it, that's way can see resolution.

i have 3 separate user classes share single-table inheritance. here are

class user < activerecord::base   has_many :notifications   def notify     #code notify user   end end  class student < user   has_many :charges   def charge_user     #code charge user   end end  class teacher < student   has_many :students   has_many :courses   def create_course     #code create course   end end 

i want able use each has_many method once, , teacher must inherit student methods

the problem if if run

teacher.find(1) 

i error

activerecord::subclassnotfound: single-table inheritance mechanism failed locate subclass: 'teacher'. error raised because column 'type' reserved storing class in case of inheritance. please rename column if didn't intend used storing inheritance class or overwrite user.inheritance_column use column information. 

if change teacher class to

class teacher < user end 

it works, however, teacher doesn't have has_many methods , normal methods student has.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -