Hi
I have two models Keyword and KeywordResult, they basically look like this:
class KeywordResult < ActiveRecord::Base
belongs_to :keyword
validates_presence_of :title, :url, :keyword_id
end
class Keyword < ActiveRecord::Base
has_many :keyword_results, :dependent => :delete_all
acts_as_tree :order => "text", :foreign_key =>
"top_keyword"
end
Before you ask: I commented all other callbacks and hooks out.
now when I want to add a KeywordResult I get a SystemStackError.
>> kw = Keyword.find(72)
=> #<Keyword:0x2595ec4
@attributes={"updated_at"=>"2006-07-25
23:50:54", "text"=>"my keyword",
"lock_version"=>"14", "id"=>"72",
"lang"=>"de", "top_keyword"=>"68",
"created_at"=>"2006-07-25
01:56:48"}>>> kw.keyword_results
=> []>> kw.keyword_results << KeywordResult.new({:title =>
"foobar", :url =>
"foobar"})
SystemStackError: stack level too deep
from
./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb:100:in
`read_inheritable_attribute''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/callbacks.rb:354:in
`callbacks_for''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/callbacks.rb:330:in
`callback''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/callbacks.rb:296:in
`valid?''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/validations.rb:743:in
`save_without_transactions''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:120:in
`save_without_validation''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:86:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:112:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:120:in
`save_without_validation''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/validations.rb:744:in
`save_without_transactions''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:120:in
`save_without_validation''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:86:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:112:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:120:in
`save_without_validation''
... 1229 levels...
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:120:in
`save_without_validation''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/validations.rb:744:in
`save_without_transactions''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:120:in
`save_without_validation''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:86:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:112:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:120:in
`save_without_validation''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/validations.rb:744:in
`save''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb:160:in
`insert_record''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:26:in
`<<''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:23:in
`<<''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:86:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:112:in
`transaction''
from
./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:22:in
`<<''
I don''t see any loops in my code (all callbacks and other validations
are commented out)
I hope you have some ideas..
Thanks, Tobias