On Nov 24, 5:10 am, Gianluca Padovani <gpadov...@gmail.com> wrote: > Hi to all, > I have this error and I don't understand why. I have three model, > Image and Playlist and PlaylistItem. Everything works fine. The app > should work also a XML REST service. When I made this call I obtain > this XML because the playlist don't contains images: > > GEThttp://0.0.0.0:3000/playlists/7.xml > <playlist> > <id>7</id> > <name>metallo</name> > <images></images> > </playlist> > > I would put some images in playlist (the images are already presents > on server) I should made this call: > > PUThttp://0.0.0.0:3000/playlists/7.xml > > <playlist> > <id>7</id> > <name>metal</name> > <images> > <image> > <id>1</id> > <name>gino</name> > </image> > <image> > <id>2</id> > <name>pino</name> > </image> > </images> > </playlist> > > but I obtain this error: > > ActiveRecord::AssociationTypeMismatch in PlaylistsController#update > Image(#87559180) expected, got Array(#78093260) > > parameters: > {"playlist"=>{"id"=>"7", > "name"=>"metal", > "images"=>{"image"=>[{"id"=>"1", > "name"=>"gino"}, > {"id"=>"2", > "name"=>"pino"}]}}, > "id"=>"7", > "format"=>"xml"}
Looks like you need a slightly different format for the XML: http://stackoverflow.com/questions/4698266/creating-multiple-resources-in-a-single-restful-post-in-rails --Matt Jones -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.