是否有可能建立某种关联:
用户型号:
has_many :goods, :through => :assignments
has_many :goods_want, :through => :assignments, :source => :good, :conditions => "assignments.type = 1"
在控制台中测试
u = User.first
u.goods_want << Good.first
u.save
正在记录:
INSERT INTO `assignments` (`good_id`, `updated_at`, `type`, `profile_id`, `created_at`) VALUES(1, '2009-03-26 09:36:11', NULL, 1, '2009-03-26 09:36:11')
那么有没有什么漂亮的方法可以使这种关联不仅从数据库中获取记录,而且可以写入数据库?