drhenner / ror_ecommerce

Ruby on Rails Ecommerce platform, perfect for your small business solution.
www.ror-e.com
MIT License
1.21k stars 409 forks source link

Making sense of ImageGroup model #149

Closed lakesare closed 8 years ago

lakesare commented 9 years ago

I can't wrap my head around how Image, ImageGroup, Variant and Product models are supposed to interact.

ImageGroup has_many :images and :variants, Product has_many :images. How is that supposed to operate? What does it mean for Image_group to have many :variants? image_group is a collection of :images. What does it mean for collection of :images to have many :variants? (My aim is to have one/multiple :images for one variant and I can't see how :image_groups belong here)

drhenner commented 9 years ago

I'll try to add something to the readme...

Basically if you have many variants with the same image just use the "products.images"

Use ImageGroups for something like shoes. Lets say you have 3 colors, and each color has 10 sizes. You would create 3 images groups (one for each color). The image for each size would be the same and hence point to the same image_group.

If you want an image for a specific ProductType you would need to model that out yourself.

Does that make sense?

lakesare commented 9 years ago

Okay. Product has multiple variants and each of these variants belongs to some image group, that is, each variant can have multiple images associated with it. I can use these connections, or we can use product's :images if we don't have different images for product's variants. Did I get it right?

drhenner commented 8 years ago

Sorry I should have confirmed your reply :( Hope all is working well