Through method problems with custom foreign_keys

A person has a many company_branches and
A company_branch has many people.
This join is represented using a “contacts” table.
I am using a legacy schema so i am forced into using non-standard rails
primary keys. I am using the new through relationship in rails 1.1.

b=p.company_branches # gives this error:

ActiveRecord::StatementInvalid: OCIError: ORA-00904:
ID”: invalid identifier: SELECT company_branches.* FROM contacts,
es WHERE (company_branches.branch_id = contacts.company_branch_id AND
erson_person_id = 1)

Notice that “contacts.company_branch_id” does not exist, it should be

Here are the models:

class Person < ActiveRecord::Base
set_primary_key “person_id”

has_many :contacts,

has_many :company_branches,

class CompanyBranch < ActiveRecord::Base

set_primary_key “branch_id”

belongs_to :company,

has_many :contacts,

class Contact < ActiveRecord::Base
set_primary_key “contact_id”

belongs_to :company_branch,

belongs_to :person,

Any idea what is wrong? Any help would be greately appreciated!

I believe I ran across the same problem when trying a self-referential
has_many :through relationship. I’ve submitted a patch at that seems to fix it for me.
You may want to give it a shot.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs