nemo
2007-Mar-19 22:30 UTC
Prototype/Virgin objects => usable objects, aka default db rows => custom db rows
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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
nemo
2007-Mar-20 20:21 UTC
Re: Prototype/Virgin objects => usable objects, aka default db rows => custom db rows
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? :) On Mar 19, 11:30 pm, "nemo" <zuperinfin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---