Scott Bronson
2006-Jan-25 05:40 UTC
[Rails] Changing the instantiated table when using STI
Is there any way to get AR to instantiate a different class when using
STI? Where it would normally instantiate Digit, I would like it to
instantiate SkelDigit. Here''s why...
My rails app has the following STI hierarchy:
Digit < Glyph < ActiveRecord::Base
My migrate script can''t use those classes directly however (backward
compatibility issues), so I created some skeleton classes:
SkelDigit < SkelGlyph < ActiveRecord::Base
This way, my migrate script can use the skelton classes to move the
data.
The problem is, the type field of the glyphs table contains "Digit",
"Letter" etc. Therefore, when I call SkelDigit.find(:all), I receive
an
array of Digit objects, not SkelDigit objects. Then, of course,
everything breaks.
Is there any way I can tell AR to instantiate a SkelDigit instead of a
Digit? It looks like AR::Base::instantiate has something to do with
this but it''s a private routine and poorly documented.
Thank you very much,
- Scott
Possibly Parallel Threads
- 8 commits - libswfdec/swfdec_bits.h libswfdec/swfdec_font.c libswfdec/swfdec_font.h libswfdec/swfdec_loader.c libswfdec/swfdec_loader_internal.h libswfdec/swfdec_tag.c libswfdec/swfdec_text.c libswfdec/swfdec_text.h test/swfedit_token.c test/various
- [PATCH v2 11/20] drm: sti: Rely on the default ->best_encoder() behavior
- [PATCH 18/23] drm/sti: Convert to CRTC VBLANK callbacks
- [PATCH v8 16/18] ARM: DT: STi: stihxxx-b2120: Add DT nodes for STi audio card
- [PATCH v8 14/18] ARM: STi: DT: STiH407: Add uniperif player dt nodes
