I have two models Purchase and Address. I\'m trying to make Address polymorphic so I can reuse it in my Purchase model fo
You need to specify the :class_name option for the has_one association, as the class name can't be inferred from the association name i.e., :shipping_address and :billing_address in your case doesn't give an idea that they refer to class Address.
Update the Purchase model as below:
class Purchase < ActiveRecord::Base
has_one :shipping_address, class_name: "Address", as: :addressable
has_one :billing_address, class_name: "Address", as: :addressable
## ...
end