Hello,
I'm experimenting with a two to many model asssociation... where I
have one or two "Primaries" for each "Secondary" and many
"secondaries" per "primary".
the following code works fine:
----------------------------------------------------------------------------------
class PrimaryTable < ActiveRecord::Base
has_many :secondary_tables_1 , :foreign_key
=> :A_primary_table_id, :class_name => "SecondaryTable"
has_many :secondary_tables_2 , :foreign_key
=> :B_primary_table_id, :class_name => "SecondaryTable"
end
class SecondaryTable < ActiveRecord::Base
belongs_to :A_primary_table, :foreign_key
=> :A_primary_table_id, :class_name => "PrimaryTable"
belongs_to :B_primary_table, :foreign_key
=> :B_primary_table_id, :class_name => "PrimaryTable"
end
------------------------------------------------------------------------------------------
But I would like my primary controller to only have one column linking
to my child secondaries instead of the two ( _1 and _2). I tried
doing something like this:
------------------------------------------------------------------------------------------
class PrimaryTable < ActiveRecord::Base
has_many :secondary_tables ,
:foreign_key => :A_primary_table_id,
:foreign_key => :B_primary_table_id,
:class_name => "SecondaryTable"
end
------------------------------------------------------------------------------------------
but B ends up being the only one that is linked in my one "Secondary
Tables" column.
Does anybody know how to combine these two in to one column? Do i
need to write a helper function for this?
Thanks,
Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---