I''m trying to work with habtm and push_with_attributes and have a
problem:
class Objekt < ActiveRecord::Base
     has_and_belongs_to_many :aktions
end
class Aktion < ActiveRecord::Base
     has_and_belongs_to_many :objekts
end
CREATE TABLE `aktions` (
   `id` int(11) NOT NULL auto_increment,
   `name` varchar(32) NOT NULL default '''',
   PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=4 ;
CREATE TABLE `aktions_objekts` (
   `aktion_id` int(11) NOT NULL default ''0'',
   `objekt_id` int(11) NOT NULL default ''0'',
   `condition` varchar(255) NOT NULL default '''',
   PRIMARY KEY  (`aktion_id`,`objekt_id`)
) TYPE=MyISAM;
CREATE TABLE `objekts` (
   `id` int(11) NOT NULL auto_increment,
   `name` varchar(32) NOT NULL default '''',
   `code` varchar(32) NOT NULL default '',
   PRIMARY KEY  (`id`),
) TYPE=MyISAM AUTO_INCREMENT=3 ;
and the following test code:
  def test_change_condition
    obj = Objekt.find(1)
    aktion = Aktion.find(1)
    obj.aktions.clear
    obj.aktions.push_with_attributes(aktion, :condition => "true" 
)
    obj.aktions.reload
    a = obj.aktions.first
    a.condition = "false"
    a.save
  end
  def test_change_aktion
    obj = Objekt.find(1)
    aktion = Aktion.find(1)
    obj.aktions.clear
    obj.aktions.push_with_attributes(aktion, :condition => "false"
);
    obj.aktions.reload
    aktion.name = "bla"
    assert aktion.save
  end
I get the following errors:
   1) Error:
test_change_aktion(ObjektTest):
ActiveRecord::StatementInvalid: Unknown column ''condition'' in
''field
list'': UPDATE aktions SET `code` = '' xyz'',
`condition` = ''false'', `id` =
''2'', `name` = ''bla'' WHERE id =
''2''
    
c:/dev/ruby/lib/ruby/gems/1.8/gems/activerecord-1.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:339:
in `log''
[...]
   2) Error:
test_change_condition(ObjektTest):
ActiveRecord::StatementInvalid: Unknown column ''objekt_id'' in
''field
list'': UPDATE aktions SET `objekt_id` = ''1'', `code` =
'' xyz'', `condition`
= ''false'', `aktion_id` = ''2'', `id` =
''2'', `name` = ''gaga'' WHERE id =
''2''
[...]
I must be missing something really trivial, but I don''t grok it... Any
ideas?
thanks
Jens-Christian