views:

13

answers:

1

I have a model with the following associations:

class Car < ActiveRecord::Base
  belongs_to :transportation_vehicle
  belongs_to :owner
  has_many :parts

  def scrap(buyer, part)
  ...
  end
end

How would I access owner and parts in the scrap method?

A: 

owner or self.owner.

Jordan
thanks Jordan. Do I need the @? I'd imagine owner would be an instance variable rather than a class variable.
Tian
to answer my own follow up, no need for @
Tian
"owner" is a method, in fact. Like many of Rails features, I believe it's generated on the fly using method_missing.
Jordan