Ok, then maybe I didn't ask properly... you are right it's not STI what
I'm trying to do, but I'll try to explain it better.

What I need is just to extend a base class (wich is a model with its db
table and all activerecord logic) with another class (a subclass with
its own table and all activerecord logic, plus the parent methods,
properties and so on). I tried to do it like I mentioned in my first
email, but when the child class (the extended class) has a fk to another
table, rails tries to find the fk in the parent class, not in the
extended class, like the example I posted before:

class Parentclass < ActiveRecord::Base 
end 

## this child class has a anotherclass_id 
class Childclass < Parentclass 
end 

class Anotherclass < ActiveRecord::Base 
  has_one :childclass 
end 

then... 

>> a = Anotherclass.find(1) 
>> a.childclass 

ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 
'parentclasses.anotherclass_id' in 'where clause': SELECT * FROM 
`parentclasses` WHERE (`parentclasses`.anotherclass_id = 1)  LIMIT 1 


is there any way to do what I'm trying to do in rails using
activerecord??

thanks



On Mon, 2010-09-13 at 03:03 -0700, Frederick Cheung wrote:
> 
> On Sep 13, 9:48 am, Javier Ruiz <[email protected]> wrote:
> > Thanks for your reply Fred, but the fk name is ok, the problem is that
> > the has_one relation goes to the wrong table, it should go to the child
> > class, not to the parent class...
> >
> You're using sti - there is only one table.
> 
> Fred
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to