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, Ike
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
this question should go to the rubyonrails mailing list.
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?
PS The fact that you could bring yourself to write belongs_to: suggests
that you don’t know Ruby. Over the course of a long life in computers I
have found that it is helpful to know the basics of the language in
which one is programming (though, to be quite honest, I’ve written quite
a bit of Perl without obeying that rule)…
Jesus H. Christ…it’s a TYPO as I was copying by hand, with from the
code
on another machine, without considering that. Thanks for being so
chastising. -Ike
You probably could have looked it up, and it should go on the rails
list. However, people don’t need to be rude. RTFM should be banned
from this list, plus the rails documentation is scattered and it sorta
sucks.
Using the column names primary_associate_id and secondary_associate_id,
instead of associatekey1 and associatekey2
Rails automatically infers the class_name and foreign_key from the name
of your association. You can always just name your association whatever
you want and specify those things explicitly, like I do here.
PS The fact that you could bring yourself to write belongs_to: suggests
that you don’t know Ruby. Over the course of a long life in computers I
have found that it is helpful to know the basics of the language in
which one is programming (though, to be quite honest, I’ve written quite
a bit of Perl without obeying that rule)…
Hah, that post was so Tom Christiansen like, 10 years ago, on the Perl
mailing list. Brings back memories.
Outside of the silly attitude, I’d just like to point out that the
placement of the colons in Ruby is very odd compared to other popular
programming languages out there. Using a :colon like a $sigil takes some
getting used to, and assuming “colon: value” is much more consistent
with JSON/YAML/etc.
Rails automatically infers the class_name and foreign_key from the name of
your association. You can always just name your association whatever you
want and specify those things explicitly, like I do here.
Thanks Mike,
I’m stuck with legacy DB column names here however – I think maybe I
need
to look deeper into the ActiveRecord source. Thanks for your help. -Ike
You probably could have looked it up, and it should go on the rails
list. However, people don’t need to be rude. RTFM should be
banned from this list, plus the rails documentation is scattered
and it sorta sucks.
BZZZZZT. This is the ruby-talk mailing list, not the rails mailing
list. Take your chastisement elsewhere.
This is also a newsgroup and I haven’t noticed any news groups for
rails. While you might not like people asking questions about one of
the programs using Ruby on your precious mailing list not everyone is as
close-minded as you seem to be.
I only found out about the mailing list after finding the newsgroup and
have found no reason to use the mailing list. I am sure that I am not
the only one.
You probably could have looked it up, and it should go on the rails
list. However, people don’t need to be rude. RTFM should be
banned from this list, plus the rails documentation is scattered
and it sorta sucks.
BZZZZZT. This is the ruby-talk mailing list, not the rails mailing
list. Take your chastisement elsewhere.
Rails-schmails. What happened to, “Matz is nice, so we are nice?”
This is also a newsgroup and I haven’t noticed any news groups for
rails. While you might not like people asking questions about one of
the programs using Ruby on your precious mailing list not everyone is as
close-minded as you seem to be.
I only found out about the mailing list after finding the newsgroup and
have found no reason to use the mailing list. I am sure that I am not
the only one.
Wow, this is getting almost as exciting as C++ land.
Ryan, you weren’t the rude one, saying “go to the rails mailing list”
was both accurate and polite. The rudeness was the other guy. I stand
by what I said, saying RTFM is cursing at a stranger, and the question
wasn’t overly rudimentary.