Hi, I''ve recently fallen in love with RoR, and I''m writing a small application just to get familiar with it, particularly AR. Things are going well, but I found STI to be somewhat counter-intuitive. So I searched the mailing lists and found John Wilger''s proposal and subsequent patch. Great, just what I was hoping for! However, I see that there has been no activity on the ticket since the end of December (http://dev.rubyonrails.com/ticket/303). Are people testing this patch and discussing it elsewhere? Does the patch work on the current release? I''d like to test it myself, but people on IRC suggested that it might be outdated by now. Thanks. -- Regards, Stian Grytøyr
On Mon, 7 Feb 2005 11:51:09 +0100, Stian Grytøyr <sgrytoyr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''ve recently fallen in love with RoR, and I''m writing a small application > just to get familiar with it, particularly AR. Things are going well, but I > found STI to be somewhat counter-intuitive. So I searched the mailing > lists and found John Wilger''s proposal and subsequent patch. Great, > just what I was hoping for! > > However, I see that there has been no activity on the ticket since the > end of December (http://dev.rubyonrails.com/ticket/303). Are people > testing this patch and discussing it elsewhere? Does the patch work > on the current release? I''d like to test it myself, but people on IRC > suggested that it might be outdated by now.That patch probably is outdated by now. DHH implemented changes some time ago so that CONTI works by default if the parent class does not have a ''type'' column in its database table. The missing piece, however, is still CLSTI (Class Table Inheritance). I''ve been working on this off and on as I have time. Since you brought it up, I went ahead and posted a patch (against the current trunk) to ActiveRecord that implements CLSTI. It is incomplete and likely full of bugs/missing features, but all of the current unit tests for ActiveRecord pass when it is included---so at least there''s that. It''s ticket #600 if you''d like to check it out. If anyone notices any glaring problems with the code, please let me know. (failing tests appreciated!) -- Regards, John Wilger ----------- Alice came to a fork in the road. "Which road do I take?" she asked. "Where do you want to go?" responded the Cheshire cat. "I don''t know," Alice answered. "Then," said the cat, "it doesn''t matter." - Lewis Carrol, Alice in Wonderland
On Mon, 7 Feb 2005 14:52:48 -0500, John Wilger <johnwilger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Since you brought it up, I went ahead and posted a patch > (against the current trunk) to ActiveRecord that implements > CLSTI. It is incomplete and likely full of bugs/missing features, > but all of the current unit tests for ActiveRecord pass when it > is included---so at least there''s that.Excellent, I''ll give it a spin! My patching skills are somewhat rusty, however, and I get complaints about missing files when I try to apply it. Can anyone spot what I''m doing wrong here? [/usr/lib/ruby/gems/1.8/gems/rails-0.9.5] # patch -p0 < /tmp/patch.diff patching file test/clsti_test.rb patching file test/fixtures/employee.rb can''t find file to patch at input line 113 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |Index: test/fixtures/topics.yml |==================================================================|--- test/fixtures/topics.yml (revision 528) |+++ test/fixtures/topics.yml (working copy) -------------------------- File to patch: -- Regards, Stian Grytøyr
Stian, I think it might be that you are patching against the "gems" version of rails and John''s patch is against the "trunk" ... Could that be the case? If that''s the case, I would suggest you get "edge rails" with svn and patch against that ... Just my 2 cents, /B On Mon, 7 Feb 2005 22:48:52 +0100, Stian Grytøyr <sgrytoyr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mon, 7 Feb 2005 14:52:48 -0500, John Wilger <johnwilger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Since you brought it up, I went ahead and posted a patch > > (against the current trunk) to ActiveRecord that implements > > CLSTI. It is incomplete and likely full of bugs/missing features, > > but all of the current unit tests for ActiveRecord pass when it > > is included---so at least there''s that. > > Excellent, I''ll give it a spin! My patching skills are somewhat rusty, > however, and I get complaints about missing files when I try to apply > it. Can anyone spot what I''m doing wrong here? > > [/usr/lib/ruby/gems/1.8/gems/rails-0.9.5] # patch -p0 < /tmp/patch.diff > patching file test/clsti_test.rb > patching file test/fixtures/employee.rb > can''t find file to patch at input line 113 > Perhaps you used the wrong -p or --strip option? > The text leading up to this was: > -------------------------- > |Index: test/fixtures/topics.yml > |==================================================================> |--- test/fixtures/topics.yml (revision 528) > |+++ test/fixtures/topics.yml (working copy) > -------------------------- > File to patch: > > -- > Regards, > Stian Grytøyr > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Bruno Mattarollo <bruno.mattarollo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Currently in: Sydney, Australia
On Tue, 8 Feb 2005 09:06:58 +1100, Bruno Mattarollo <bruno.mattarollo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Stian, I think it might be that you are patching against the "gems" > version of rails and John''s patch is against the "trunk" ... Could > that be the case? If that''s the case, I would suggest you get "edge > rails" with svn and patch against that ...Turns out I was trying to patch Rails, not ActiveRecord. It still complains that "Hunk #1 FAILED at 4" in test/fixtures/topics.yml, but apart from that I think I''m OK. But you are right about me using the gems version, so I may still get in trouble. We''ll see. Time to actually test the patch... -- Regards, Stian Grytøyr
On Mon, 7 Feb 2005 14:52:48 -0500, John Wilger <johnwilger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It''s ticket #600 if you''d like to check it out. If anyone notices any > glaring problems with the code, please let me know. (failing tests > appreciated!)I''m not really up to speed on how to use the automated tests yet, but I am unable to get this to work. With the code below I get undefined method `clsti_parent'' for User:Class or undefined method `find_all'' for User:Class I get the first message the first times I load /user/list after I restart Apache. If I change the code in user.rb, for example by changing the class definition to "class User < Person" (which gives me the message MultipleParentsDefined), then back again, I get the latter message on subsequent reloads. This may be because I''m running the gems version of everything. If no one can spot any glaring errors in the logic/code below, I''ll try the trunk version later on. Thinks to note in my code is that I''ve created the User model class with no OO inheritance, which I understood was the right thing to do. Also, I''m not quite sure about the actual syntax for clsti_parent. CREATE TABLE people ( id int primary key, firstname varchar(100), lastname varchar(100) ) CREATE TABLE users ( id int primary key, username varchar(20), password varchar(100), person_id int ) app/model/person.rb: class Person < ActiveRecord::Base end app/model/user.rb: class User clsti_parent Person end app/controllers/user_controller.rb: class UserController < ApplicationController scaffold :user end -- Regards, Stian Grytøyr