I have following active record class
class Car < ActiveRecord::Base
belongs_to :owner
end
in the code when I try this
Car.first.owner
it gives me error “undefined method owner”
Can any one plz let me now if I’m missing any thing
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to write the relation on the Owner side :
has_one :carorhas_many :carsdepending on your needs.