views:

75

answers:

1

hi

i have a rails app that currently uses activerecord to store and query products.

Each product has a category and sub category and each sub category is defined by multiple field that i can create within the application. From this when a user wants to input a specific product, they are pressented with the relevent form fields.

This has become very complex and having since hearing about mongodb and mongomapper, i think or wish i created it from the start in using mongomapper !!!

Problem is i want to know the best way to model this app in mongodb ???

I was thinking of having a procuct model with common fields and then having category models inheriting from product model with the different fields in.

Does this sound correct ?

Problem is as well is that i want the user to be able to create there own category and fields from within the application. How can i do this as when a user for example creates a cars category with fields like speed and number of doors etc. I then need to be able to create a form using these fields for future cars to be inputted.

Any ideas, pointers or examples anyone can help me with would be great.

Thanks alot in advance rick

A: 
Gates VP
thanks Gates VP for your help.I need to also store the units for each field ie car length is mm, car weight is kg and revs = rpm etcAny idea how to incorperate this into your solution ?thanks alotrick
rick moss
Just modify the "Category" collection. I made "fields" into an array of "pairs" (key-value). However, you can make it an array of objects. I've updated the reply with this at the bottom.
Gates VP