Forum: Ruby on Rails Problem with relation ship using fixtures

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Naga harish K. (Guest)
on 2009-01-07 16:16
Hi all,
  I am having a problem with the relation ship with the fixtures.

My rails version is 2.2.2, and am using the old style of fixtures.

My models are

Class Account < ActiveRecord::Base
 has_many :users

Class User < ActiveRecord::Base
 belongs_to :account

My Fixtures are

 id: 1
 name: Harish
 account_id: 1
 id: 2
 name: Rahul
 account_id: 1

 id: 1
 name: Account1

so in my model code if I have
1   user = User.find(user_id)

Then its giving NoMethodError in Line #2
when I try user.account its giving #<Account> class but is failing.

I also tried with the new fixtures as per Rails 2.0 still same problem.
What I might be missing?
Any thing should be loaded??
This code is working in Rails 1.2.3 previously, but now its not
Can any one help with this??
This topic is locked and can not be replied to.