Prototype/Virgin objects => usable objects, aka default db r


#1

Hellos,

I’m kinda stumped, so hopefully someone can help me out.

I have a custom_modules table, in which I’ve defined default modules
for a skinnable website I’m designing. Those modules have default
values, such as css class, position (left/right) and so on.

When a user registers with the site, he gets a fresh new Template
object, which has_many :custom_modules. However, these are the
“prototype”, or virgin objects from my rows in that table. What I want
to do is make a copy of those for my newly instantiated template, so
the user can safely modify his own custom_modules.

Any ideas on how to achieve this?

thanks a bunch!


#2

Ok, after some more researching on the topic, I think I need to use
has_many :through.
Maybe stuff all the user specified changes in the join model, and keep
an link to the original module, and values, using the join itself. I
just can’t get my head around implementing it. Can anyone spare a
minute? :slight_smile: