[Rails] Selection of STI and CONTI (ticket 303)

Stian Grytøyr sgrytoyr at gmail.com
Tue Feb 8 11:03:54 GMT 2005


On Mon, 7 Feb 2005 14:52:48 -0500, John Wilger <johnwilger at gmail.com> 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


More information about the Rails mailing list