So I have the following model class Topic < ActiveRecord::Base belongs_to :topic has_many :topics, :order => :position acts_as_tree :order => :position acts_as_list :scope => :topic_id end that I use for a site''s navigation. Everything (list, create, edit, even the drag&drop sort) works fine, except the destroy function, which the vanilla version def destroy Topic.find(params[:id]).destroy redirect_to :action => ''list'' end which gives me the following error "Mysql::Error: Unknown column ''topics.parent_id'' in ''where clause'': SELECT * FROM topics WHERE (topics.parent_id = 39) ORDER BY position" Now, my table has the normal "id" field and a "topic_id" field that I am using instead of "parent_id", so I have have both - a list and a tree. And, like I said, it works great and I was surprised at how simple the whole thing was - until I tried to delete a topic and the whole thing exploded. I also already tried belongs_to :topic, :foreign_key => ''topic_id'', :class_name => ''Topic'' but that producced the same error. So. Uhm. Help? :o) Thanks for your time guys! Samo -- Posted via http://www.ruby-forum.com/.
Thomas
2006-May-30 09:00 UTC
[Rails] Re: acts_as_tree, acts_as_list and is invincible (help!)
Hi, Shouldn''t you specifiy the options foreign_key in your acts_as_tree call ? As you do not use the default column name parent_id, I would try something like that : acts_as_tree :order => :position, :foreign_key => ''topic_id'' Bye, Thomas. -- Posted via http://www.ruby-forum.com/.
samo
2006-May-30 09:24 UTC
[Rails] Re: acts_as_tree, acts_as_list and is invincible (help!)
I''m a newbie when it comes to Rails, so I didn''t know that (actually I tried the foreign_key at all the wrong places...). Anyhow, thanks a lot - that solved it! Samo Thomas wrote:> Hi, > > Shouldn''t you specifiy the options foreign_key in your acts_as_tree call > ? As you do not use the default column name parent_id, I would try > something like that : > > acts_as_tree :order => :position, :foreign_key => ''topic_id'' > > Bye, > Thomas.-- Posted via http://www.ruby-forum.com/.
Reasonably Related Threads
- acts_as_tree & acts_as_list for a single model?
- acts_as_tree with acts_as_list
- acts_as_list / acts_as_tree / acts_as_nested_set - which one
- Using set_primary_key breaks acts_as_tree with non-integer column
- counter_cache is not looking for children_count with acts_as_tree