Multi Table Inheritance with rails 3

2019-01-17 11:31发布

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?

3条回答
你好瞎i
2楼-- · 2019-01-17 12:05

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楼-- · 2019-01-17 12:22

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

查看更多
三岁会撩人
4楼-- · 2019-01-17 12:27

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.

查看更多
登录 后发表回答