I have a model with a belongs_to
association:
class Car < ActiveRecord::Base
belongs_to :vendor
end
So I can call car.vendor
. But I also want to call car.company
! So, I have the following:
class Car < ActiveRecord::Base
belongs_to :vendor
def company
vendor
end
end
but that doesn't solve the assignment situation car.company = 'ford'
, so I need to create another method for that. Is there a simple alias
mechanism I can use for associations? Can I just use alias_method :company, :vendor
and alias_method :company=, :vendor=
?