Guest User

Untitled

a guest
Apr 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. class Product < ActiveRecord::Base
  2. belongs_to :buyable, :polymorphic => true
  3. end
  4.  
  5.  
  6. class Wine < ActiveRecord::Base
  7. has_one :product, :as => :buyable
  8. end
  9.  
  10. # this works
  11. @wine = Wine.find(:first)
  12. @wine.product.attribute_x -> "the value as expected"
  13.  
  14. # how do i get this one to work?
  15. @product = Product.find(:first)
  16. @product.wine.attribute_x -> undefined method wine
Add Comment
Please, Sign In to add comment