I have an active record class
class Car < ActiveRecord::Base belongs_to :owner end
in code when i try to do this
Car.first.owner
it gives me the error "undefined method owner"
Can anyone plz allow me now if I miss something?
You need to write a relationship from the owner's side: has_one :car or has_many :cars depending on your needs.
has_one :car
has_many :cars
class Car < ActiveRecord::Base belongs_to :owner end class Owner < ActiveRecord::Base has_one :car end