single table inheritance - Rails STI: Forbidding parent class initialization -


i have rails model book, sti-inherited models fiction , nonfiction

while book holds lot of common logic, i'd forbid creation of parent book model. wondering elegant method doing in rails - suggestions appreciated

you raise error in book's initializer

class book   def initialize *args     raise "can't create book" if self.class == book     super # if it's not book, proceed activerecord initialization   end end 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -