Vitor HP
2013-Mar-28 21:02 UTC
Multiple has_one associations with polymorphic associations
Hi, guys. I''m having trouble setting this polymorphic association say that i have this setup class User has_one :face_photo, as: :imageable, class_name: "Image", dependent: :destroy has_one :body_photo, as: :imageable, class_name: "Image", dependent: :destroy end class Image belongs_to :imageable, polymorphic: true end Both face_photo and body_photo are being saved with the images table with the imageable_type == "User", so when i try to get body_photo from a user, it brings me its face_photo. Is there a way i can specify the type that goes in the imageable type so it can bring me the right image? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.