0

I have an application managing software tests and a class called TestResult:

class TestResult < ActiveRecord::Base
  belongs_to :test_case,   :class_name => "TestCase"
end

I'm right now migrating from Rails 1.x to 2.3.5.

In Rails 1.x everything works fine.

When trying to access the association in Rails 2.3.5, I get the following error:

NoMethodError: undefined method 'find' for ActiveRecord::TestCase:Class from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/belongs_to_association.rb:49:in 'send'

from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/belongs_to_association.rb:49:in 'find_target'

from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:239:in 'load_target'

from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:112:in 'reload'

from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1250:in 'test_case'

My Question is: how can I tell Rails to use my TestCase-class instead of ActiveRecord::TestCase.

TestCase class:

class TestCase < ActiveRecord::Base

  set_table_name "test_case"

  has_many   :test_results
  belongs_to :component,         :foreign_key => "subsystem_id"
  belongs_to :domain,            :foreign_key => "area_id"
  belongs_to :use_case,          :foreign_key => "use_case_id"
end
3
  • why are you migrating to rail 2.3.5? current version is 2.3.8? And if you already do the work, I would try to migrate to rails 3.0, because it is due soon Commented May 28, 2010 at 10:51
  • I believe if ruby is looking for ActiveRecord::TestCase it didn't found TestCase. Can you post some more code? the TestCase Class? Commented May 28, 2010 at 10:53
  • why 2.3.5? well, just started migrating like two month ago and forgot to update rails meanwhile. did the upgrade right now, but does not solve this problem. As there seems to be no rails 3 release date and we have to finish migration due to end of june, the time is just too short... Commented May 28, 2010 at 11:05

2 Answers 2

1

what about

class TestResult < ActiveRecord::Base
  belongs_to :test_case, :class_name => "::TestCase"
end
Sign up to request clarification or add additional context in comments.

Comments

0

what about

class TestResult < ActiveRecord::Base
  belongs_to :test_case
end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.