# Mysterious StackError with habtm on destroy

**URL:** <https://www.ruby-forum.com/t/mysterious-stackerror-with-habtm-on-destroy/70526>\
**Category:** Engines Development\
**Created:** [February 19, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/mysterious-stackerror-with-habtm-on-destroy/70526 "2006-02-19T18:35:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhutter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@mhutter](https://www.ruby-forum.com/u/mhutter)\
**Post date:** [February 19, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/mysterious-stackerror-with-habtm-on-destroy/70526/1 "2006-02-19T18:35:58Z")

</div>

Hi

I am getting a kind of mysterious error when deleting a group in my  
unit tests. I get this error when calling the “destroy” action in my  
controller, so the only different thing is that it is called from a  
unit test instead of running in Webrick.

I am calling Group.find(params[:id]).destroy in my controller. Group  
has\_and\_belongs\_to\_many User and Role objects. The same code does not  
give errors when running as a component but it does when running as  
an Engine. Thus, I suspect something is breaking along the way.

Has anyone else experienced a problem like this?

Regards,

Manuel

====

This is the error:

1. Error:  
test\_should\_destroy\_group\_on\_destroy\_post\_with\_answer\_yes\_and\_valid\_grou  
p\_id(ActiveRbac::GroupControllerTest):  
SystemStackError: stack level too deep  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/activerecord/lib/active\_record/associations.rb:  
752:in `users' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/activerecord/lib/active_record/associations.rb: 750:in`users’  
(eval):3:in `destroy_without_habtm_shim_for_roles' (eval):4:in`destroy\_without\_habtm\_shim\_for\_users’

```
 [these two lines are repeated a lot of times]

 (eval):4:in `destroy_without_callbacks'
 /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/

```

rbac\_demo/vendor/rails/activerecord/lib/active\_record/callbacks.rb:  
321:in `destroy_without_transactions' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/activerecord/lib/active_record/transactions.rb: 122:in`destroy’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/activerecord/lib/active\_record/transactions.rb:  
122:in `transaction' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/activerecord/lib/active_record/transactions.rb: 91:in`transaction’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/activerecord/lib/active\_record/transactions.rb:  
118:in `transaction' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/activerecord/lib/active_record/transactions.rb: 122:in`destroy’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/plugins/active\_rbac/app/controllers/active\_rbac/  
group\_controller.rb:131:in `destroy' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/actionpack/lib/action_controller/base.rb: 853:in`send’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/actionpack/lib/action\_controller/base.rb:  
853:in `perform_action_without_filters' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/actionpack/lib/action_controller/filters.rb: 332:in`perform\_action\_without\_benchmark’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/actionpack/lib/action\_controller/  
benchmarking.rb:69:in `perform_action_without_rescue' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/actionpack/lib/action_controller/ benchmarking.rb:69:in`measure’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/actionpack/lib/action\_controller/  
benchmarking.rb:69:in `perform_action_without_rescue' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/actionpack/lib/action_controller/rescue.rb: 82:in`perform\_action’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/actionpack/lib/action\_controller/base.rb:  
369:in `send' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/actionpack/lib/action_controller/base.rb: 369:in`process\_without\_session\_management\_support’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/actionpack/lib/action\_controller/  
session\_management.rb:116:in `process_without_test' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/actionpack/lib/action_controller/ test_process.rb:16:in`process’  
/Users/manuel/Development/Rails/arbac.ts.com/rbac\_demo/trunk/  
rbac\_demo/vendor/rails/actionpack/lib/action\_controller/  
test\_process.rb:300:in `process' /Users/manuel/Development/Rails/arbac.ts.com/rbac_demo/trunk/ rbac_demo/vendor/rails/actionpack/lib/action_controller/ test_process.rb:307:in`post’  
vendor/plugins/active\_rbac/test/functional/  
group\_controller\_test.rb:245:in  
`test\_should\_destroy\_group\_on\_destroy\_post\_with\_answer\_yes\_and\_valid\_gro  
up\_id’

---

<div class="post-metadata">

**Author:** ![mhutter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@mhutter](https://www.ruby-forum.com/u/mhutter)\
**Post date:** [February 19, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/mysterious-stackerror-with-habtm-on-destroy/70526/2 "2006-02-19T19:54:55Z")

</div>

Am 19.02.2006 um 15:56 schrieb Manuel H.:

> an Engine. Thus, I suspect something is breaking along the way.
> 
> Has anyone else experienced a problem like this?

Never mind. I solved this by making sure that my User model file was  
only included once. I tried to run the same tests as a component  
would require and did not read the documentation of Engines before.

Regards,

Manuel
