sferik/rails_admin — Issue #973: association inserted correctly then updated to null
Author: philsmy
Created: 2012-02-10 02:58:26+00:00
State: open

I have classes:

class TopLevelDomain < ActiveRecord::Base
has_many :featured_lottery_info_top_level_domains
has_many :featured_lottery_infos, :through => :featured_lottery_info_top_level_domains
end

and

class FeaturedLotteryInfoTopLevelDomain < ActiveRecord::Base
belongs_to :featured_lottery_info, :class_name => "LotteryInfo"
belongs_to :top_level_domain
end

The form gives me the chance to add a lottery into the featured lottery infos. But this happens:

[1m[35mSQL (0.3ms)[0m INSERT INTO `featured_lottery_info_top_level_domains` (`created_at`, `featured_lottery_info_id`, `top_level_domain_id`, `updated_at`) VALUES ('2012-02-10 02:54:12', 2, 1, '2012-02-10 02:54:12')

[1m[36m (0.6ms)[0m [1mCOMMIT[0m
[1m[35mFeaturedLotteryInfoTopLevelDomain Load (0.4ms)[0m SELECT `featured_lottery_info_top_level_domains`.* FROM `featured_lottery_info_top_level_domains` WHERE `featured_lottery_info_top_level_domains`.`id` = 1 LIMIT 1
[1m[36m (0.1ms)[0m [1mBEGIN[0m
[1m[35mSQL (0.3ms)[0m UPDATE `featured_lottery_info_top_level_domains` SET `top_level_domain_id` = NULL WHERE `featured_lottery_info_top_level_domains`.`top_level_domain_id` = 1 AND `featured_lottery_info_top_level_domains`.`id` IN (2)
[1m[36m (1.2ms)[0m [1mCOMMIT[0m

So, it inserts properly then immediately updates the record to have null in the top_level_domain_id.

I assume that I am doing something wrong... just not sure what!