association

Hi...... I would like to know what i ve done wrong in my association. I have 4 Models. user_info company_info department role

Actually i want to get Particular user's company,and which department he belongs and what role he has... These inforamtions i would like to get. So i made association.

class CompanyInfo < ActiveRecord::Base

The setup seems to be right, assuming there is a company_info_id in the user_info table.

Are the records in the database ok and have the right id? What code do you use to get the CompanyInfo? Something like:

@user_info = UserInfo(:first)

That should allow to acces it like that: @user_info.company_info

It seems all of your "has_one" should be has_many. A company, role and department should have many users. That might reduce problems with your associations.