Problem with .to_xml and Hash.form_xml ?


i m trying to do some kind of database dump using .to_xml and after i try to fill my database back (well an other) with the content of the xml.

Right now i m doing that :

@xml = Video.find(:all).to_xml(:include=>[:vlogiciels])

it does produce :

<videos>    <video>         <mycolumns>         .....         <vlogiciels>             <logiciel>                <my vlogiciels columns>                ...            </logiciel>          </vlogiciels>       .....     </video> </videos>

Then i try to do :

and then i ve got this error : undefined method `videos=' for #<Video: 0x3f6e82c>

I guess the problem is caused by the <videos> tag into the xml... ? Anyway i don t know how to solve my problem, if someone could give me an hand, i googled since 2hours without reel success :(...

Maybe it s a tricky question, but i m stuck :frowning:


no one does have any clue for me ?


Differenthink wrote:

@xml = Video.find(:all).to_xml(:include=>[:vlogiciels])

Then i try to do :

I maybe can help a little. Instead of find(:all .., try find(:first .... I understand that that is now what you want eventually. But, I think your problem is that is going to return one Video but your @xml is an array of Videos.

Thanks for your post. I did what you told me, i ve got an : NoMethodError: undefined method 'video=' for #<video:XXXX> it seems that it didn t like the first tag <video>...