In my model, if I have a field, that contains the id to another table,
twice
(like, primary associate and a secondary associate) I am specifying
this as
class Customer < ActiveRecord::Base
belongs_to: associate :foreign_key => "associatekey1"
belongs_to: associate :foreign_key => "associatekey2"
end
This doesn't work -- but my question is how SHOULD the syntax for
specifying
this look? Thanks, Ralph
class Customer < ActiveRecord::Base
belongs_to: associate :foreign_key => "associatekey1"
belongs_to: associate :foreign_key => "associatekey2"
end
On the ruby-talk mailing list (where this question originated), Ike has
stated that his belongs_to lines above are actually typos due to a
from-memory manual re-typing of the code. The assumption is that s/he
is using the correct syntax (properly placed colons and commas).
The colons should appear at the start of the association name (the name is a symbol) rather than after belongs_to, you need a comma between the two arguments to belongs_to, and the two associations should have different names.