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
this question should go to the rubyonrails mailing list.
···
On Oct 31, 2006, at 11:00 AM, Ike wrote:
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
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)...
···
Ike <rxv@hotmail.com> wrote:
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?
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
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)...
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
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
BZZZZZT. This is the ruby-talk mailing list, not the rails mailing list. Take your chastisement elsewhere.
···
On Oct 31, 2006, at 12:04 PM, Mike Harris wrote:
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.
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?"
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.
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.
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
I just changed the names of the columns in my example cause I felt like it. This is perfectly fine as well
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.
Wow, this is getting almost as exciting as C++ land.