An Article from Aaron's Article ArchiveRuby ActiveRecord Newbie Question (Answered) and a PHP Cake/Rails Question
Photo: Close-up of Sand in BloomIPv4You are not logged in. Click here to log in.
Use Google to search aarongifford.com:
Ruby ActiveRecord Newbie Question (Answered) and a PHP Cake/Rails Question
Wednesday, 15 August 2007 2:14 PM MDT
I'm using Ruby's ActiveRecord single-table inheritance to define several types of objects. I've got a burning question that perhaps someone may be able to answer for me.
[NOTE: I've since answered this question, though I would still love to hear an answer to the question at the bottom of this post.]
Read on, and if you can help me, please send me a message.
First, an example of an ActiveRecord set of classes:
In the above, class
What if I want to make sure that for any particular set of
I can think of many ways that are quite cumbersome to enforce this restriction, but nothing simple and elegant.
It would be nice to even be able to create a new
UPDATE: (Later, the same day as the above question was first posted)
With a little experimentation with the
Of course this is only enforced if I don't bypass ActiveRecord's normal operation and set the
There's nothing like yet-even-more online searching of documentation to answer one's own questions.
Oh, and here's another only vaguely related question: Does anyone know if PHP Cake's implementation of ActiveRecord is 1:1 compatible with Ruby's ActiveRecord such that a PHP application and a Rails application could share a single back-end database data store? Think of it, the PHP app. creates an object, saves it, then sometime later, the Ruby app. accessess and modifies the object. It would be a thing of beauty.
UPDATE II: Electric Boogaloo
Now that I'm more familiar with Cake, it turns out it isn't really a PHP implementation of the Active Record though overall it shares some similar behaviors. So it definitely is NOT 1:1 compatible with Ruby's Active Record, though I'm sure with a little extra code one could get an application in one to work with objects from an application that uses the other.