From 14dcefaa97f93e07f44b260e1083c69f0f1c356f Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Tue, 21 Aug 2012 17:15:59 +0000 Subject: [PATCH] set default category_id instead of the object (#11665) Rails 2.3 still has issues with synchronizing the association_id and association attributes of an object. That means, if you set the association with an object first and then just set the id afterwards, the object wins and the setting of the id gets lost. This is not an issue in Rails >= 3.1 anymore. Contributed by Holger Just. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10226 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/document.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/document.rb b/app/models/document.rb index d4a89ffd9..764dea7f0 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -42,7 +42,9 @@ class Document < ActiveRecord::Base def initialize(attributes=nil, *args) super if new_record? - self.category ||= DocumentCategory.default + # Rails3 use this instead + # self.category ||= DocumentCategory.default + self.category_id = DocumentCategory.default.id if self.category_id == 0 end end