[Rails] habtm recursion via destroy_without_callbacks
M Daggett
heavysixer at gmail.com
Mon Jan 2 00:32:12 GMT 2006
I am having the same problem. I think that it has something to do with
mysql. As of yet, I have no solutions for the problem.
On 12/31/05, Eric Soderberg <soderic at earthlink.net> wrote:
> I am having a problem with two models that each have a HABTM
> relationship to the other. For example:
>
> CREATE TABLE people (id INT, name TEXT);
> CREATE TABLE teams (id INT, name TEXT);
> CREATE TABLE people_teams (person_id INT, team_id INT);
>
> The person model has:
>
> has_and_belongs_to_many :teams
>
> And the team model has:
>
> has_and_belongs_to_many :people
>
> The trouble comes when trying to destroy something, I end up with a
> recursive stack sequence that looks something like:
>
> (eval):7:in `destroy_without_habtm_shim_for_teams'
> (eval):9:in `destroy_without_habtm_shim_for_teams'
> (eval):9:in `destroy_without_callbacks'
> ...
>
> This appears to be due to something in associations.rb where the
> association array is cleared as part of destroying the record. What
> appears to be happening is that when person.rb is loaded, its HABTM
> causes team.rb to be loaded which ends up reloading person.rb? I've
> added some instrumentation that shows that the
> destroy_without_habtm_shim_for_teams method ends up being added twice.
> This causes recursion when the record is destroyed. I've worked around
> this by embedding this method aliasing inside an "unless
> method_defined?()" to prevent the recursive situation. However, I'm
> suspecting that I'm missing something else obvious.
>
> I am using activerecord 1.13.2 and rails 1.0.0.
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
--------------------------------------------------------------------
I am Mark Daggett and I approve this message.
More information about the Rails
mailing list