ruby - XML:Mapping and object to table -
my task make xml mapping xml:mapping in ruby , save object database. here class:
class offer < activerecord::base include xml::mapping text_node :offer_id , "@id" array_node :pictures, "picture", :class => picture text_node :scu, "vendorcode" end
binding works fine
irb(main):003:0> o = offer.new => #<offer id: nil, offer_id: nil, scu: nil, created_at: nil, updated_at: nil> irb(main):004:0> o= offer.load_from_file("c:\\simple.xml") => #<offer id: nil, offer_id: nil, scu: nil, created_at: nil, updated_at: nil>
hash empty , not good. but:
irb(main):005:0> o.scu => "52.61.037"
o.save makes blank row in database because of empty hash. how can save xml-mapping object database?
Comments
Post a Comment