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
This commit is contained in:
1 parent
f4a7d6ca8c
commit
14dcefaa97
1 file changed
+3
-1
@@ -42,7 +42,9 @@ class Document < ActiveRecord::Base
|
|||||||
def initialize(attributes=nil, *args)
|
def initialize(attributes=nil, *args)
|
||||||
super
|
super
|
||||||
if new_record?
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user