diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-08-21 17:15:59 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-08-21 17:15:59 +0000 |
commit | 14dcefaa97f93e07f44b260e1083c69f0f1c356f (patch) | |
tree | 1d8c5548795d0efc701f77e490eb1498d1543a78 | |
parent | f4a7d6ca8cd2a3bc1f40f0e8c54d95f3dfa91117 (diff) | |
download | redmine-14dcefaa97f93e07f44b260e1083c69f0f1c356f.tar.gz redmine-14dcefaa97f93e07f44b260e1083c69f0f1c356f.zip |
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
-rw-r--r-- | app/models/document.rb | 4 |
1 files changed, 3 insertions, 1 deletions
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 |