# Rails habtm grief am I dumb or rails bug? (desperate ; )

**URL:** <https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677>\
**Category:** Rails\
**Created:** [April 13, 2011, 3:15am UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677 "2011-04-13T03:15:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 13, 2011, 3:15am UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/1 "2011-04-13T03:15:20Z")

</div>

Greetings all,

I’m having a weird problem with a habtm relationship and honestly  
I’m beginning to think I may have stumbled upon some weird bug in  
rails 3. Surely I’m crazy though. I’ve been beating my head against  
the wall on this for 3 days, have googled everything under the sun I  
can think of and still can’t come up with an answer.

Ok, the situation:

I’m creating a Rails app to replace both a Java app and a PHP app  
(java application and php front-end). This is going to be a phased  
operation with the first phase being the Rails application takes over  
registration and billing. In order to do this, the Rails application  
must create data in the databases for the Java and PHP apps. The  
Rails application itself is using Devise for authentication.

In database.yml I have my standard 3 databases defined and also a  
connection defined for the Java apps database.  
Here are pieces of the model definitions for the external object (I’m  
just creating regular rails models to talk to the external databases):

class Pushbroom::UserAccount \< ActiveRecord::Base  
require ‘digest/md5’  
require ‘base64’

establish\_connection :pushbroom  
set\_table\_name :user\_account  
set\_primary\_key :id

has\_and\_belongs\_to\_many :user\_roles, :join\_table =\>  
‘pb\_prod.users\_roles’, :class\_name =\>  
‘Pushbroom::UserRole’, :foreign\_key =\>  
‘user\_account\_id’, :association\_foreign\_key =\> ‘user\_role\_id’  
belongs\_to :user, :dependent =\> :destroy

attr\_accessible :user\_roles, :admin\_notes, :enabled, :username,  
:password\_hash, :prefStore, :accepted\_tos, :do\_not\_contact

end

class Pushbroom::UserRole \< ActiveRecord::Base

establish\_connection :pushbroom  
set\_table\_name :user\_role  
set\_primary\_key :id

has\_and\_belongs\_to\_many :user\_accounts, :join\_table =\>  
‘pb\_prod.users\_roles’, :class\_name =\>  
‘Pushbroom::UserAccount’, :foreign\_key =\>  
‘user\_role\_id’, :association\_foreign\_key =\> ‘user\_account\_id’

end

And finally my Rails application user object:

class User \< ActiveRecord::Base

before\_validation :capture\_plaintext\_password, :on =\> :create  
before\_save :create\_pushbroom\_user\_data  
after\_save :send\_welcome\_email

# Include default devise modules. Others available are:

# :token\_authenticatable, :encryptable, :confirmable, :lockable,

:timeoutable  
and :omniauthable  
devise :database\_authenticatable, :registerable,  
:recoverable, :rememberable, :trackable, :validatable

belongs\_to :pb\_user\_account, :class\_name =\>  
“Pushbroom::UserAccount”, :foreign\_key =\>  
“pb\_user\_account\_id”, :dependent =\> :destroy, :autosave =\> true

# Setup accessible (or protected) attributes for your model

attr\_accessible :first\_name, :last\_name, :username, :dob, :email,  
:password, :password\_confirmation, :remember\_me

validates\_presence\_of :first\_name, :last\_name, :username, :dob  
validates\_date :dob, :on\_or\_after =\> lambda  
{ 100.years.ago }, :on\_or\_after\_message =\> “must be on or after  
#{100.years.ago.strftime(’%m-%d-%Y’)}”  
validates\_date :dob, :on\_or\_before =\> lambda  
{ 13.years.ago }, :on\_or\_before\_message =\> “must be on or before  
#{13.years.ago.strftime(’%m-%d-%Y’)}”

def capture\_plaintext\_password  
@plaintext\_password = self.password  
end

def create\_pushbroom\_user\_data  
pb\_user = create\_pushbroom\_user  
add\_trial\_subscription\_to\_pb\_user(pb\_user)  
pb\_user\_account = create\_pushbroom\_user\_account(pb\_user)  
add\_subscription\_plan\_roles\_to\_pb\_user\_account(pb\_user\_account)  
self.pb\_user\_account = pb\_user\_account  
end

def create\_pushbroom\_user  
pb\_user = Pushbroom::User.new  
pb\_user.attributes = self.attributes.slice(  
“email”,  
“first\_name”,  
“last\_name”,  
“dob”)

```
pb_user

```

end

def add\_trial\_subscription\_to\_pb\_user(pb\_user)  
subscription = Pushbroom::Subscription.new

subscription.populate\_from\_subscription\_plan(Pushbroom::SubscriptionPlan.find\_by\_name(“TRIAL”))  
pb\_user.subscriptions \<\< subscription  
end

def add\_subscription\_plan\_roles\_to\_pb\_user\_account(pb\_user\_account)  
roles\_granted =  
pb\_user\_account.user.subscriptions.first.subscription\_plan.roles\_granted  
pb\_user\_account.user\_roles = roles\_granted  
end

def create\_pushbroom\_user\_account(pb\_user)  
pb\_user\_account = Pushbroom::UserAccount.new  
pb\_user\_account.enabled = true  
pb\_user\_account.password\_hash =  
Pushbroom::UserAccount.create\_password\_digest(@plaintext\_password,  
self.username)  
pb\_user\_account.username = self.username  
pb\_user\_account.user = pb\_user

```
pb_user_account

```

end

def send\_welcome\_email  
AccountMailer.welcome(self).deliver  
end  
end

Seems like it should be pretty vanilla. The ONLY weirdness here is  
that they aren’t in the native rails database and one of the fields is  
named funny in the relations table.

So here’s a rails console session where I create a rails user, call  
the method to create the external objects, then try to save:

ruby-1.9.2-p180 :001 \> def user\_fred  
ruby-1.9.2-p180 :002?\> {  
ruby-1.9.2-p180 :003 \> :first\_name =\> “Fred”,  
ruby-1.9.2-p180 :004 \> :last\_name =\> “Flinstone”,  
ruby-1.9.2-p180 :005 \> :username =\> “fflint”,  
ruby-1.9.2-p180 :006 \> :dob =\> “1986-06-01”,  
ruby-1.9.2-p180 :007 \> :email =\> “removed\_email\_address@domain.invalid”,  
ruby-1.9.2-p180 :008 \> :password =\> “badpass”  
ruby-1.9.2-p180 :009?\> }  
ruby-1.9.2-p180 :010?\> end  
=\> nil  
ruby-1.9.2-p180 :011 \> user = User.new(user\_fred)  
=\> #\<User id: nil, email: “removed\_email\_address@domain.invalid”, encrypted\_password:  
“$2a$10$IiEOEoSnXIrP7VJAQYckfOVXuzm7Y5ZGo20ayLpSkHhz…”,  
reset\_password\_token: nil, remember\_created\_at: nil, sign\_in\_count: 0,  
current\_sign\_in\_at: nil, last\_sign\_in\_at: nil, current\_sign\_in\_ip:  
nil, last\_sign\_in\_ip: nil, created\_at: nil, updated\_at: nil,  
first\_name: “Fred”, last\_name: “Flinstone”, username: “fflint”, dob:  
“1986-06-01”, pb\_user\_account\_id: nil\>  
ruby-1.9.2-p180 :012 \> user.create\_pushbroom\_user\_data  
=\> #\<Pushbroom::UserAccount id: nil, created\_by: nil, created\_at:  
nil, updated\_by: nil, updated\_at: nil, admin\_notes: nil, enabled:  
true, username: “fflint”, password\_hash: “blah blah”, user\_id: nil,  
prefStore: nil, accepted\_tos: nil, do\_not\_contact: nil\>  
ruby-1.9.2-p180 :013 \> user.pb\_user\_account.user\_roles  
=\> [#\<Pushbroom::UserRole id: 1, created\_by: “script”, created\_at:  
“2008-11-10 12:10:44”, updated\_by: “script”, updated\_at: “2008-11-10  
12:10:44”, admin\_notes: “”, name: “user”, description: “Generic User  
Role”, conditional: false\>]  
ruby-1.9.2-p180 :014 \> user.save!  
NoMethodError: undefined method `relation' for nil:NilClass from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activesupport-3.0.5/lib/active_support/whiny_nil.rb:48:in`method\_missing’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/arel-2.0.9/  
lib/arel/insert\_manager.rb:22:in `insert' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/arel-2.0.9/ lib/arel/crud.rb:26:in`insert’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/associations/  
has\_and\_belongs\_to\_many\_association.rb:76:in `insert_record' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/associations/association_proxy.rb: 151:in`send’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/autosave\_association.rb:306:in  
`block in save_collection_association' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/associations/ association_collection.rb:431:in`block in method\_missing’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/associations/association\_proxy.rb:  
216:in `block in method_missing' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/associations/association_proxy.rb: 216:in`each’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/associations/association\_proxy.rb:  
216:in `method_missing' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/associations/ association_collection.rb:431:in`method\_missing’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/autosave\_association.rb:297:in  
`save_collection_association' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/autosave_association.rb:163:in`block in add\_autosave\_association\_callbacks’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activesupport-3.0.5/lib/active\_support/callbacks.rb:415:in  
`_run_create_callbacks' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/callbacks.rb:281:in`create’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/persistence.rb:246:in  
`create_or_update' ... 18 levels... from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/callbacks.rb:277:in`create\_or\_update’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/persistence.rb:56:in `save!' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/validations.rb:49:in`save!’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/attribute\_methods/dirty.rb:30:in  
`save!' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/transactions.rb:245:in`block in  
save!’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/transactions.rb:292:in `block in with_transaction_returning_status' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/connection_adapters/abstract/ database_statements.rb:139:in`transaction’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/transactions.rb:207:in  
`transaction' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ activerecord-3.0.5/lib/active_record/transactions.rb:290:in`with\_transaction\_returning\_status’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
activerecord-3.0.5/lib/active\_record/transactions.rb:245:in `save!' from (irb):14 from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ railties-3.0.5/lib/rails/commands/console.rb:44:in`start’  
from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/  
railties-3.0.5/lib/rails/commands/console.rb:8:in `start' from /Users/gander/.rvm/gems/ruby-1.9.2-p180@sms2/gems/ railties-3.0.5/lib/rails/commands.rb:23:in`\<top (required)\>’  
from script/rails:6:in `require' from script/rails:6:in`'ruby-1.9.2-p180 :015 \>

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 ; )

Any insight into this is EXTREMELY appreciated!

Gerald

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 13, 2011, 2:07pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/2 "2011-04-13T14:07:31Z")

</div>

On Apr 13, 2:13am, Gerald A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 13, 2011, 2:11pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/3 "2011-04-13T14:11:51Z")

</div>

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 : /

G

On Apr 13, 6:16am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 13, 2011, 2:15pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/4 "2011-04-13T14:15:34Z")

</div>

Another note along these lines. . . if I load an existing user with  
existing roles, they load fine. It just won’t let me add new ones.

G

On Apr 13, 6:16am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 13, 2011, 2:19pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/5 "2011-04-13T14:19:55Z")

</div>

On Apr 13, 1:06pm, Gerald A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 13, 2011, 6:55pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/6 "2011-04-13T18:55:09Z")

</div>

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:18am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 13, 2011, 7:47pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/7 "2011-04-13T19:47:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 14, 2011, 1:49pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/8 "2011-04-14T13:49:12Z")

</div>

On Apr 13, 1:20pm, Gerald A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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.

Short of finding and squashing the bug, one not-too-smelly alternative  
might be to make a real model for users\_roles, like this:

class UsersRoles \< ActiveRecord::Base  
establish\_connection :pushbroom  
set\_primary\_key nil

belongs\_to :user\_account, :class\_name =\> ‘PushBroom::UserAccount’  
belongs\_to :user\_role, :class\_name =\> ‘PushBroom::UserRole’  
end

then you could replace the habtm call with a set of  
has\_many :throughs, which shouldn’t have the same problem (since  
you’ve explicitly told Rails the join table is on the :pushbroom  
connection).

–Matt J.

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 14, 2011, 1:59pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/9 "2011-04-14T13:59:06Z")

</div>

Good timing, just got it fixed (non-smelly)and you’re pretty close to  
the mark.

The answer? has\_many :through - something I’d never taking much of a  
look at, but it is actually a pretty nice feature (even in other  
circumstances).

Basically this just allows me to create a model class which represents  
the relationship. And since I have a model class for it I can  
explicitly specify the database to connect to.

For posterity sake, here’s the code:

class Pushbroom::UsersRolesRelationship \< ActiveRecord::Base

establish\_connection :pushbroom  
set\_table\_name :users\_roles

belongs\_to :user\_account  
belongs\_to :user\_role  
end

class Pushbroom::UserAccount \< ActiveRecord::Base

establish\_connection :pushbroom  
set\_table\_name :user\_account  
set\_primary\_key :id

has\_many :users\_roles\_relationships  
has\_many :user\_roles, :through  
=\> :users\_roles\_relationships, :source =\> :user\_role  
end

class Pushbroom::UserRole \< ActiveRecord::Base

establish\_connection :pushbroom  
set\_table\_name :user\_role  
set\_primary\_key :id

has\_many :users\_roles\_relationships  
has\_many :user\_accounts, :through  
=\> :users\_roles\_relationships, :source =\> :user\_account  
end

And is used thusly:

def add\_subscription\_plan\_roles\_to\_pb\_user\_account(pb\_user\_account)  
roles\_granted =  
pb\_user\_account.user.subscriptions.first.subscription\_plan.roles\_granted  
pb\_user\_account.user\_roles = roles\_granted  
end

Thanks a ton folks for helping me get this train moving again! All my  
tests are passing and it seems to be working, but if you see something  
wrong, please do still let me know.

Thanks!  
Gerald

---

<div class="post-metadata">

**Author:** ![gander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@gander](https://www.ruby-forum.com/u/gander)\
**Post date:** [April 14, 2011, 2:00pm UTC](https://www.ruby-forum.com/t/rails-habtm-grief-am-i-dumb-or-rails-bug-desperate/205677/10 "2011-04-14T14:00:56Z")

</div>

Oh, also meant to say I don’t know that the habtm thing is a bug (not  
a feature either : b). It’s not the way I would like to see it work  
but the rails code that I looked at just flat doesn’t make allowances  
for m2m relationship tables outside of the rails db that I could tell.

Gerald
