Hi everybody, Is there a way in Rails to create Active Record model objects from YAML just like you can with XML? -Tiffani A.B. --~--~---------~--~----~------------~-------~--~----~ 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 1/15/07, Tiffani Ashley Bell <tiffani2k3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi everybody, > > Is there a way in Rails to create Active Record model objects from YAML just > like you can with XML? > > -Tiffani A.B.Foo.new(YAML.load(@yaml_data)) http://ruby-doc.org/stdlib/libdoc/yaml/rdoc/index.html -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
Rick Olson wrote:> Foo.new(YAML.load(@yaml_data))This is my chance to ask about something I''ve wondered about: when I write test fixture /yml files, I include the id value for each record. But normally the id is supposed to be an auto-increment integer column. So how does the fixture loading code allow the fixture data to supply the id? In other words, how does it override this behavior and assign the id manually? Thanks Jeff --~--~---------~--~----~------------~-------~--~----~ 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 1/15/07, Jeff <cohen.jeff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Rick Olson wrote: > > Foo.new(YAML.load(@yaml_data)) > > This is my chance to ask about something I''ve wondered about: when I > write test fixture /yml files, I include the id value for each record. > But normally the id is supposed to be an auto-increment integer column. > > So how does the fixture loading code allow the fixture data to supply > the id? In other words, how does it override this behavior and assign > the id manually?It doesn''t use AR, it just inserts into the DB. Exhibit A: http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/fixtures.rb#L286 -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---