Saturday, January 16, 2010

[Rails] Re: polymorphic associations and STI

Hello

If I'm not completely wrong what you want is just STI:

class Message < ActiveRecord::Base
belongs_to :post
end

class Letter < Message
end

class Post < ActiveRecord::Base
has_many :messages
has_many :letters
end

For each inherited model of Message that you access by
Post.inherited_modelname(s) (like in Post.first.letters) you need a
has_many declaration in the Post class.

Regards, T.
--
Posted via http://www.ruby-forum.com/.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate