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?
your Company needs one additional field
owner_id :integer
then add to Company
belongs_to :owner, :class_name => "User"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With