Extending API of recalculate_attributes_for

This way we may not need to fetch an entry from the DB, where an existing object
is already present. This might be of special intrest, when plugins alias-method
chain recalculate_attributes_for and want to save a separate save call.
pull/3/head
Gregor Schmidt 12 years ago committed by Martin Czuchra
parent ccc97fcbfa
commit 9755b931dd
  1. 8
      app/models/issue.rb

@ -772,7 +772,13 @@ class Issue < ActiveRecord::Base
end
def recalculate_attributes_for(issue_id)
if issue_id && p = Issue.find_by_id(issue_id)
if issue_id.is_a? Issue
p = issue_id
else
p = Issue.find_by_id(issue_id)
end
if p
# priority = highest priority of children
if priority_position = p.children.maximum("#{IssuePriority.table_name}.position", :include => :priority)
p.priority = IssuePriority.find_by_position(priority_position)

Loading…
Cancel
Save