Draw an ER diagram of your DB and all will be clear. :-)
------------
| category |
------------
| |
/|\ /|\
----------- ------------
| pages | | images |
----------- ------------
Looks OK to me.
--
-- Tom Mornini
On Sep 21, 2005, at 8:17 PM, Raymond Brigleb wrote:
> I was struggling with some code today and realized that I have two
> tables belonging to one parent. Is this even possible? Say for
> instance I have a "categories" table. There''s also a
"pages" and an
> "images" table. I''ve got something like this in my code:
>
> class Category < ActionRecord::Base
> has_many :pages
> has_many :images
> end
>
> class Page < ActionRecord::Base
> belongs_to :category
> end
>
> class Image < ActionRecord::Base
> belongs_to :category
> end
>
> Is this even remotely valid, or have I been sitting in front of
> this computer for too long?!? Is there a smarter way to go about
> this sort of thing?
>
> -Raymond
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>