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.
George G. (Guest)
on 2007-03-28 08: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
Michael W. (Guest)
on 2007-03-28 14:15
(Received via mailing list)
Tanzanite T. wrote:
> join table is however named feature_cvterm (rails would expect one
>
> Thanks
>

has_and_belongs_to_many :cvterm, :join_table => "feature_cvterm"


--
Michael W.
George G. (Guest)
on 2007-03-28 22:05
Michael W. wrote:
> Tanzanite T. wrote:
>> join table is however named feature_cvterm (rails would expect one
>>
>> Thanks
>>
>
> has_and_belongs_to_many :cvterm, :join_table => "feature_cvterm"
>
>
> --
> Michael W.



Thanks Michael,--

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