Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

HABTM no longer works when using multiple databases

#3190

The check has_primary_key? in has_and_belongs_to_many_association.rb fails when using multiple databases because it uses ActiveRecord::Base's connection and not the correct connection for the association.

This change changes it to use the @owner connection.

This first broke on this commit
http://github.com/rails/rails/commit/9c1bac0b7fcb627640db6824dca3e6...
- which was removed by commit http://github.com/rails/rails/commit/594a281d663dd8a7801651f4aea7e5... - but was again added by this commit http://github.com/rails/rails/commit/2b82708b0efb3a3458e8177beab58f...

I enclose a patch to fix it.

Reported by sds · September 11th, 2009 @ 11:03 AM

State: duplicate
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. José Valim
    José Valim

    Actually, I think we should remove the code all together. The feature is great, but the implementation is very slow. My patch attemps to solve it, but fails in Postgres for a strange reason.

    September 11th, 2009 @ 09:04 PM

  2. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to duplicate

    September 11th, 2009 @ 10:10 PM

  3. erzapito
    erzapito

    the delete_records method also fails:

    line 90 is:
    @c.delete(sql)

    and should be:
    @owner.connection.delete(sql)

    October 16th, 2009 @ 11:46 AM