I think possibly you want product belongs_to raw_category and product
belongs_to category through raw_category. It has to be that way round
because you need raw_category has_many products.
Then you need category has_many raw_categories and raw_category
belongs_to product. You can also then say category has_many products
through raw_categories.
Are you sure you need this complexity however? You could just have
product belongs_to category (and the reverse) and work out which one
it is when you parse the xml, by looking it up in the raw_categories
table.
Colin
Colin
> I estimate that there will be about 40k to 100k products in the database.
> Regards
> Linus
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/zGGWZr75nPMJ.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
Yes, if there is the slightest possibility of wanting to do this then
that is the way to go.
> On the other hand, it might be very inefficient to do it like that... It
> would save some database work with a direct relation between products and my
> categories.
Don't worry about efficiency. I can virtually guarantee that the
critical issues for performance will not be those you imagine at the
start of a project. You can worry about that much later in the
unlikely event that you need to.
Colin