11

I have a model called company and one called user, and User belongs to Company and Company has many Users.

But I want to store on the company model the master company admin user, but I want to do it with a custom name.

So, i want to do this: comapany.owner.name .

How can I do this in Rails 3?

Mateus Pinheiro
  • 870
  • 2
  • 12
  • 20

1 Answers1

16

your Company needs one additional field

owner_id :integer

then add to Company

belongs_to :owner, :class_name => "User"
m4risU
  • 1,231
  • 11
  • 14