[Rails] Circular dependency problem

gros gros thomas.gros at gmail.com
Wed Mar 1 10:43:50 GMT 2006


Hello,

I use rails 1.0
It seems that i encounter a circular dependency problem, and i can't 
manage to solve it.

With the following models

class Customer < ActiveRecord::Base
  has_and_belongs_to_many :projects
end

class Project < ActiveRecord::Base
  has_and_belongs_to_many :customers
end

And a file test.rhtml containg only
<%= Customer.count %>

I get the following error. Can someone explain me why and how to solve 
it ?
(P.S.: search is disabled on this forum so maybe it's already explained 
somewhere but ... :-))

e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in 
`load'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in 
`load'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:in 
`require_or_load'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in 
`depend_on'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:30:in 
`associate_with'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:179:in 
`require_association'
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:179:in 
`require_association'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:780:in 
`require_association_class'
e:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:650:in 
`has_and_belongs_to_many_without_reflection'
(eval):5:in `has_and_belongs_to_many'
#{RAILS_ROOT}/app/models/customer.rb:2
#{RAILS_ROOT}/app/views/search/test.rhtml:1
-e:3:in `load'
-e:3

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list