简体   繁体   中英

Access Active Record Object Attributes in Rails Model

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?

ownerself.owner

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM