Forum: Ruby on Rails overiding concatenation of tables by alphabetical order

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D9e14f1be0972ff1f393cc87dbd072e1?d=identicon&s=25 George George (tanzanite)
on 2007-03-28 06:33
Hi everyone!

When doing a has_and_belongs_to_many join, with two tables, rails
expects a join table whose name is the concatenation of the two table
names in an alphabetical order.

However i have a number of tables which do not follow this convection
and wish to have rails read and recognize them.

for example i have a table called feature and another called cvterm. The
join table is however named feature_cvterm (rails would expect one
called cvterm_feature) So it happily responds by generating an error
that the table can't be found or rather the class,

i wish to have rails recognize the feature_cvterm join table.

Which is the easiest way to do it?

Please forgive my ignorance

( again the tribulations of working with a legacy database.)

Thanks
Dfd6f9989147955682701da8227df8b4?d=identicon&s=25 Michael Wang (Guest)
on 2007-03-28 12:15
(Received via mailing list)
Tanzanite Tanzanite wrote:
> join table is however named feature_cvterm (rails would expect one
>
> Thanks
>

has_and_belongs_to_many :cvterm, :join_table => "feature_cvterm"


--
Michael Wang
D9e14f1be0972ff1f393cc87dbd072e1?d=identicon&s=25 George George (tanzanite)
on 2007-03-28 20:05
Michael Wang wrote:
> Tanzanite Tanzanite wrote:
>> join table is however named feature_cvterm (rails would expect one
>>
>> Thanks
>>
>
> has_and_belongs_to_many :cvterm, :join_table => "feature_cvterm"
>
>
> --
> Michael Wang



Thanks Michael,--

i got it.
This topic is locked and can not be replied to.