Hi, I like to save www-forms into one text-field in database by using XML. Example: <user> <firstname>Bill</firstname> <lastname>Gates</lastname> .... </user> And not to make 100*n fields into table. Is there any easy way for this? Add/Edit/Show data..? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I like to save www-forms into one text-field in database by using XML. > > And not to make 100*n fields into table.Hi, you could define the virtual (=not mapped to db fields) attributes in your model through attr_accessor. Then you could use the after_find and before_save callbacks to write the contents of these attributes as XML into your single text field, as well as deserialize them back into the virtual attributes when a model object is loaded from database. Jan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 20 Apr 2008, at 13:04, Gi Ga wrote:> > Hi, > > I like to save www-forms into one text-field in database by using XML. > > Example: > > <user> > <firstname>Bill</firstname> > <lastname>Gates</lastname> > .... > </user> > > And not to make 100*n fields into table. >You do realize that is really quite limiting? For example you cannot efficiently pick the first 10 users ordered by last name, select those users with property x and so on. You will also have to provide accessors for all the attributes, although I imagine it would not be hard to generate those at run time (similar to what ActiveRecord does). Fred> Is there any easy way for this? Add/Edit/Show data..? > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---