Grr, have had two meetings in the middle of all this, forgive my lack
of coherence.  Bottom line is it looks like it instantiates the engine
as the rails database and with no way (that I know of) of specifying
which db to look at for the relation table I'm kind of screwed.  It
seems to ignore the fact that I'm using :join_table =>
'pb_prod.users_roles" for the relationship definition (pb_prod is the
external database) and isn't picking up which database to use from
either object (connection :pushbroom).

So it looks to me, at the moment, as though I'm stuck.  It does bother
me though that it LOADS the relationships fine.  Just seems to be a
problem on inserts.

Again, just spouting what I've found and desperately looking for a
solution.  Would prefer to find out I'm just being an idiot instead of
having to implement some solution with seriously high code smell.

Thanks!
G



On Apr 13, 11:44 am, Gerald Anderson <[email protected]> wrote:
> Ok, so I've never put a debugger on a rails app before, wasn't real
> excited to do so ; )
>
> But. . I did.  I'm still poking around, BUT it LOOKS as though it MAY
> (like all the emphasis?) not know that the users_role table is in
> pb_prod (external db) even though it DOES know that the two
> ActiveRecord objects are and there's explicit declaration in my habtm
> key definitions.  Details:
>
> in arel-2.0.9/lib/arel/table.rb:101
>   It's returning false for table_exists? (well, returns nil because of
> that)
> That's calling table.rb:121 which says:
>   @table_exists? ||= tables.key?("pb_prod.users_roles")  ||
> engine.connection.table_exists?("user_account_id")
>
> Now, to me it looks like the values for those two or backwards (key
> implies key, not table name, and reverse for table_exists?) but. .
> key? returns false, and table_exists? sends me to:
>
> activerecord-3.0.5/lib/active_record/connection_adapters/abstract/
> schema_statements.rb:20
>
>       def table_exists?(table_name)
>         tables.include?(table_name.to_s)
>       end
>
> And, don't you know it, tables contains the rails database tables not
> the external application's tables.
>
> So. . it IS looking at the wrong database.
>
> Ok, now what?  I've tried explicitly stating in the key definitions
> for the habtm what schema to look at.  Any suggestions on what to look
> at from here?
>
> Thanks again!
>
> G
>
> On Apr 13, 7:18 am, Frederick Cheung <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > On Apr 13, 1:06 pm, Gerald Anderson <[email protected]> wrote:
>
> > > Fred, thanks for the reply.  That would seem to be logical and one of
> > > the first things I checked.  The table definition for the relationship
> > > table is (pulled straight from the production db):
>
> > > CREATE TABLE IF NOT EXISTS `users_roles` (
> > >   `user_account_id` bigint(20) NOT NULL,
> > >   `user_role_id` bigint(20) NOT NULL,
> > >   KEY `FKF6CCD9C617041664` (`user_role_id`),
> > >   KEY `FKF6CCD9C63044D5F0` (`user_account_id`)
> > > ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> > > Any other ideas (or do you see something I don't)?  This one is
> > > driving me nuts and has me totally shut down : /
>
> > I'd double check the sql statemnts rails generates when it is listing
> > columns to see if they're going to the right database.
> > Have you tried stepping though the rails insert process in the
> > debugger to see where it dies?
>
> > Fred
>
> > > G
>
> > > On Apr 13, 6:16 am, Frederick Cheung <[email protected]>
> > > wrote:
>
> > > > On Apr 13, 2:13 am, Gerald Anderson <[email protected]> wrote:
>
> > > > > If I remove the role assignment, everything is just peachy (finds,
> > > > > saves, destroys, etc), but the second I try to save roles everything
> > > > > blows sky-high with this message that, frankly, I don't get.  It knows
> > > > > its got the roles, there is no nil object that I can tell. . .and
> > > > > basically if I wasn't already bald I'd be pulling my hair out ; )
>
> > > > A cursory examination of the arel code suggests this might happen if
> > > > one of the columns you name doesn't in fact exist
>
> > > > Fred
>
> > > > > Any insight into this is EXTREMELY appreciated!
>
> > > > > Gerald

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to