Forum: Ruby on Rails YAML model initializations

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6a37d700463f35c873eff170bed4eee1?d=identicon&s=25 Tiffani Ashley Bell (Guest)
on 2007-01-16 03:52
(Received via mailing list)
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.
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2007-01-16 04:01
(Received via mailing list)
On 1/15/07, Tiffani Ashley Bell <tiffani2k3@gmail.com> 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
8217faf2bfdfa7daf10135d41ddd421e?d=identicon&s=25 Jeff Cohen (jeff)
on 2007-01-16 04:27
(Received via mailing list)
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
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2007-01-16 06:17
(Received via mailing list)
On 1/15/07, Jeff <cohen.jeff@gmail.com> wrote:
> 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/activerec...

--
Rick Olson
http://weblog.techno-weenie.net
http://mephistoblog.com
This topic is locked and can not be replied to.