Reputation: 5105
I don't want to reinvent the wheel here so would really appreciate some advice!
I get the feeling that there's a 'standard' model for entity->attribute->value system?
Attributes are pre-defined for each entity, so when the instance "Dave's Party" is created, the user needs to be asked specific questions depending on which "services" he requires. Eg. if he requires lighting, he needs to be asked if about the budget and colour, and the values that he gives need to be saved in the correct format, or picked from a set of pre-defined options.
Thanks for any help, and apologies for how I've listed the data below, hopefully how it makes sense!
services = [stage,lighting,sound,tent]
lighting.info_types = [budget,colour]
lighting.size.type = options lighting.size.options = [small,medium,large]
lighting.info_types.colour.type = options lighting.info_types['colour'].options = [red,green,blue]
lighting.info_types.budget.type = currency
tent.info_types = [size,type,capacity]
....
stage.info_types = [size,powered,raised,stage_type]
....
"a specific event "dave's party" requires small stage with a red lighting budget of £300"
@event = Event.create :name => "Dave's Party"
@event.services = [stage,lighting,sound]
What info_types does lighting have and what are the correct format for the responses?
@event.services.lighting.size = large
@event.services.lighting.colour = red
@event.services.lighting.budget = 300.00
....
Which services does Dave's Party require? What are the info_types and values for each of the services?
...
Upvotes: 0
Views: 85
Reputation: 96484
I would use a bunch of table and models for the data for light, sound, color, capacity, budget_type, etc. and use ActiveRecord and then you can use standard and familiar queries to manage the data. If you have values that need to be set up initially for the application use the seeds.rb file. You can scaffold them up in a few seconds for prototyping.
Others may recommend sti/polymorphism but unless you are already fairly confident in those areas I would recommend KISS and just separate tables. Tables/models are just so easy to do in rails!
Upvotes: 1