![]() | Recipe 15 one to many not working |
|
08 Jan 2010, 10:13
Riccardo Tacconi (3 posts) |
Hi, I have a one to many relationship between one DB and another. This is my connectino class to the ‘legacy db’: class Intranet2Database < ActiveRecord::Base
self.abstract_class = true
establish_connection(:intranet2_db) unless connected?
ActiveRecord::Base.pluralize_table_names = false I have a model class mapping a table in the legacy database: require ‘intranet2_db’ class Dept < Intranet2Database set_table_name :dept set_primary_key ‘deptID’
As you can see the table is dept, it is not plural, and cannot be renamed. I have a table in the new DB named teams: class Team < ActiveRecord::Base
belongs_to :dept and has a dept_id key that shoule map the dept.deptID primary key. When I try to acccess the dept row related to a teams row I get this: $ script/console So the problem is: ActiveRecord::StatementInvalid: Could not find table ‘dept’ Can you see any error in my code? |
|
12 Jan 2010, 12:27
Maik Schmidt (110 posts) |
Hi Riccardo! Could you, please, provide some more details:
Your posting is in the wrong forum (it’s the forum for my first book). I’ll ask my publisher, if it’s possible to move it to the right one, so don’t be surprised, if it “disappears”. Cheers, Maik |
| You must be logged in to comment |

