diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-08 20:37:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-08 20:37:12 +0000 |
commit | 42d2bf0bafcec34c54dbadfdc3136c674c826962 (patch) | |
tree | 18b5441282187d92910af8d9acf25d3893faa325 /app/models/issue.rb | |
parent | d75bc5774f1e36a1a6fa1e750a785c07c7d288c0 (diff) | |
download | redmine-42d2bf0bafcec34c54dbadfdc3136c674c826962.tar.gz redmine-42d2bf0bafcec34c54dbadfdc3136c674c826962.zip |
Makes project and tracker assigned first in #attributes=
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8131 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 9eb567c9e..7a580737c 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -238,17 +238,21 @@ class Issue < ActiveRecord::Base write_attribute(:description, arg) end - # Overrides attributes= so that tracker_id gets assigned first - def attributes_with_tracker_first=(new_attributes, *args) + # Overrides attributes= so that project and tracker get assigned first + def attributes_with_project_and_tracker_first=(new_attributes, *args) return if new_attributes.nil? - new_tracker_id = new_attributes['tracker_id'] || new_attributes[:tracker_id] - if new_tracker_id - self.tracker_id = new_tracker_id + attrs = new_attributes.dup + attrs.stringify_keys! + + %w(project project_id tracker tracker_id).each do |attr| + if attrs.has_key?(attr) + send "#{attr}=", attrs.delete(attr) + end end - send :attributes_without_tracker_first=, new_attributes, *args + send :attributes_without_project_and_tracker_first=, attrs, *args end # Do not redefine alias chain on reload (see #4838) - alias_method_chain(:attributes=, :tracker_first) unless method_defined?(:attributes_without_tracker_first=) + alias_method_chain(:attributes=, :project_and_tracker_first) unless method_defined?(:attributes_without_project_and_tracker_first=) def estimated_hours=(h) write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h) |