I''m just wondering. Is there an easy way to take a hash that I have and store it in a DB text column and then read it as a hash from it again. The reason is that I have a db table called contents. But it stores all kinds of information and even data that I do not know of yet. I know I could store it inside the text column using XML or YAML or something else but then I would have to write some sort of parser to change the data between the two. So I was hoping that there was some way of simply storing the hash without conversion in the text field and get it back as a hash. -- -------------- Jon Gretar Borgthorsson http://www.jongretar.net/
On Jun 30, 2006, at 9:30 AM, Jon Gretar Borgthorsson wrote:> I''m just wondering. Is there an easy way to take a hash that I have > and store it in a DB text column and then read it as a hash from it > again. > > The reason is that I have a db table called contents. But it stores > all kinds of information and even data that I do not know of yet. > > I know I could store it inside the text column using XML or YAML or > something else but then I would have to write some sort of parser to > change the data between the two. So I was hoping that there was some > way of simply storing the hash without conversion in the text field > and get it back as a hash. > > -- > -------------- > Jon Gretar Borgthorsson > http://www.jongretar.net/ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsclass MyModel < AR::Base serialize :free_form_data end then just have a free_form_data column in your db table and AR will take care of serializing and deserializing your hash or other objects. -Ezra
> then just have a free_form_data column in your db table and AR will > take care of serializing and deserializing your hash or other objects.What is the datatype of the column? -- Posted via http://www.ruby-forum.com/.
On Jun 30, 2006, at 10:04 AM, Jon wrote:>> then just have a free_form_data column in your db table and AR will >> take care of serializing and deserializing your hash or other >> objects. > > What is the datatype of the column? > > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsjust use :text -Ezra
On 6/30/06, Ezra Zygmuntowicz <ezmobius@gmail.com> wrote:> > class MyModel < AR::Base > > serialize :free_form_data > > end > > then just have a free_form_data column in your db table and AR will > take care of serializing and deserializing your hash or other objects.Excellent. I''ll try that. -- -------------- Jon Gretar Borgthorsson http://www.jongretar.net/
I tried the ways above but not working. Please help.'' Jón Borgþórsson wrote:> On 6/30/06, Ezra Zygmuntowicz <ezmobius-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> class MyModel < AR::Base >> >> serialize :free_form_data >> >> end >> >> then just have a free_form_data column in your db table and AR will >> take care of serializing and deserializing your hash or other objects. > > Excellent. I''ll try that. > ---- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---