Hi all,
I am running into problems with my model relationships and
destroying them. In particular:
class Campaign < ActiveRecord::Base
has_and_belongs_to_many :tags
has_and_belongs_to_many :geographies
end
class Tag < ActiveRecord::Base
has_and_belongs_to_many :campaigns
end
class Geographies < ActiveRecord::Base
has_and_belongs_to_many :campaigns
end
class TagController < ApplicationController
...
def destroy
tag = Tag.find(:first, :conditions => ["id = ?",params[:id]])
tag.connection.delete("DELETE FROM campaigns_tags WHERE tag_id =
'"+tag.id.to_s+"'") if tag.connection.execute("SELECT * FROM
campaigns_tags WHERE tag_id = '"+tag.id.to_s+"'")
tag.connection.delete("DELETE FROM spotprofile_taggings WHERE
tag_id = '"+tag.id.to_s+"'") if tag.connection.execute("SELECT * FROM
spotprofile_taggings WHERE tag_id = '"+tag.id.to_s+"'")
tag.destroy
redirect_to session[:back_page]
end
So, I have a symmetric habtm relationship between campaigns and tags,
and campaigns and geographies. Why, when I attempt to "really"
destroy the tag in the next to last line of the controller, do I get
this stack trace?
A SystemStackError occurred in tag#destroy:
stack level too deep
/usr/lib64/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/
associations/association_proxy.rb:123:in `load_target'
.
.
.