views:

400

answers:

1

I am trying to add multiple HABTM relationships through ActiveResource, but I am running into a lot of trouble. It seems that in a traditional rails app (i.e. all ActiveRecord), you can simply set your HABTM ids, and do something as such:

habtm = {:category_ids => [1,2,3]}
article.update_attributes(habtm)

Unfortunately, when I try to do this through ActiveResource, I get an error because it cannot convert the array into valid xml. I understand why it cannot, but I am stuck, and cant figure out how to solve this problem.

Any ideas?

Thanks

A: 

I am having the same troubles. If I put my migrations up here can someone assist?

(Server side)

class CreateServices < ActiveRecord::Migration
  def self.up
    create_table :services do |t|
      t.string :name
    end

    create_table :profiles_services, :id => false do |t|
      t.integer :profile_id
      t.integer :service_id
    end
  end

  def self.down
    drop_table :services
    drop_table :profiles_services
  end
end

class CreateProfiles < ActiveRecord::Migration
  def self.up
    create_table :profiles do |t|
      t.integer :status_id
      t.string  :practice_name,    :limit => 100 
      t.timestamps
    end
  end

  def self.down
    drop_table :geo_profiles
  end
end

My goal is to successfully inmplement HABTM checkboxes on the client side. More so, it appears that the to_xml method does not like a single dimension array.

Martin