>1 has_many between two tables

I want an object ‘a’ with two members x[ ] and y [ ] where both are
collections of type class B - thus my table for B contains two types of

Is this a sensible implementation?

class A
has_many :type_1
:class => “B”
:foreign_key => “a_id”
:conditions “where type=1”
has_many :type_2
:class => “B”
:foreign_key => “a_id”
:condition “where type=2”

If you want list like behavior for your x and y array then have to use
acts_as_list declaration. Without knowing your application requirements,
is difficult to suggest anything.

The option for class name should be: :class_name. Except for that, it
fine. You may also want to specify the :dependent attribute.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs