Multi Table Inheritance with rails 3

2019-01-17 11:51发布

问题:

Are there standards or best practices yet when it comes to multi table inheritance in rails 3? So far the best article I could find was:

http://mediumexposure.com/multiple-table-inheritance-active-record/

But even that needed some changes(e.g. moving the requires to an initializer instead of the old /config/environment.rb)

Any better resources / standards?

回答1:

There's a guy in the Melbourne Ruby group I attend that's written a couple of blogs on table inheritance in rails and the comments are really helpful as well. It's not specifically Rails 3 but there's definitely some decent pointers in there.

http://rhnh.net/2010/08/15/class-table-inheritance-and-eager-loading

http://rhnh.net/2010/07/02/3-reasons-why-you-should-not-use-single-table-inheritance

happy reading



回答2:

For an easy way to do multi-table inheritance take a look at 'acts_as_relation' plugin https://github.com/hzamani/acts_as_relation.



回答3:

I recently forked a promising gem to implement multiple table inheritance and class inheritance in Rails. I have spent a few days subjecting it to rapid development, fixes, commenting and documentation and have re-released it as CITIER (Class Inheritance and Table Inheritance Embeddings for Rails).

Consider giving it a look: https://github.com/PeterHamilton/citier

It actually takes some concepts from that article you mention.