# Habtm destroy problem

**URL:** <https://www.ruby-forum.com/t/habtm-destroy-problem/116854>\
**Category:** Rails\
**Created:** [October 10, 2007, 12:32pm UTC](https://www.ruby-forum.com/t/habtm-destroy-problem/116854 "2007-10-10T12:32:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![squil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@squil](https://www.ruby-forum.com/u/squil)\
**Post date:** [October 10, 2007, 12:32pm UTC](https://www.ruby-forum.com/t/habtm-destroy-problem/116854/1 "2007-10-10T12:32:35Z")

</div>

hi,  
I’m new to rails, and I have a problem. I have a habtm relationship  
between Book and Author models. I’ve got the database, and it almost  
works, except that I can’t destroy anything. When I try to destroy a  
book or an author, either from the website or console, I get the  
following error:

NameError: uninitialized constant Book::Authors  
from ./script/…/config/…/config/…/vendor/rails/activerecord/  
lib/…/…/activesupport/lib/active\_support/dependencies.rb:478:in  
`const_missing' from (eval):3:in`destroy\_without\_callbacks’  
from ./script/…/config/…/config/…/vendor/rails/activerecord/  
lib/active\_record/callbacks.rb:321:in `destroy_without_transactions' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/transactions.rb:125:in`destroy’  
from ./script/…/config/…/config/…/vendor/rails/activerecord/  
lib/active\_record/connection\_adapters/abstract/database\_statements.rb:  
59:in `transaction' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/transactions.rb:95:in`transaction’  
from ./script/…/config/…/config/…/vendor/rails/activerecord/  
lib/active\_record/transactions.rb:121:in `transaction' from ./script/../config/../config/../vendor/rails/activerecord/ lib/active_record/transactions.rb:125:in`destroy’  
from (irb):3

I used scaffolding, I didn’t make any changes except migration files,  
and I have no idea what seems to be the problem. Any ideas?

squil

---

<div class="post-metadata">

**Author:** ![squil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@squil](https://www.ruby-forum.com/u/squil)\
**Post date:** [October 10, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/habtm-destroy-problem/116854/2 "2007-10-10T15:10:44Z")

</div>

On 10/10/07, squil [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hi,  
> I’m new to rails, and I have a problem. I have a habtm relationship  
> between Book and Author models. I’ve got the database, and it almost  
> works, except that I can’t destroy anything. When I try to destroy a  
> book or an author, either from the website or console, I get the  
> following error:
> 
> NameError: uninitialized constant Book::Authors

Just a guess, but it looks like it’s looking for a model called  
Authors instead of Author,  
What are the model class names? What do your habtm declarations look  
like?

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
