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:
GET http://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: PUT http://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"} This are the three models: class Image < ActiveRecord::Base attr_accessor :picture validates :name, :uniqueness => true, :presence => true validates :picture, :presence => true has_many :playlist_items has_many :playlists, :through => :playlist_items end class Playlist < ActiveRecord::Base validates :name, :presence => true, :uniqueness => true has_many :playlist_items has_many :images, :through => :playlist_items accepts_nested_attributes_for :images, :allow_destroy => true end class PlaylistItem < ActiveRecord::Base belongs_to :image belongs_to :playlist end The project can be found here: https://github.com/gpad/rms can anybody help? thanks Gianluca -- 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.