Rails4: replace deprecated Relation#update_all at Project#create_time_entry_activity_if_needed
git-svn-id: http://svn.redmine.org/redmine/trunk@12614 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1c71eccff2
commit
073b403bd9
|
@ -249,18 +249,17 @@ class Project < ActiveRecord::Base
|
|||
# does not successfully save.
|
||||
def create_time_entry_activity_if_needed(activity)
|
||||
if activity['parent_id']
|
||||
|
||||
parent_activity = TimeEntryActivity.find(activity['parent_id'])
|
||||
activity['name'] = parent_activity.name
|
||||
activity['position'] = parent_activity.position
|
||||
|
||||
if Enumeration.overridding_change?(activity, parent_activity)
|
||||
project_activity = self.time_entry_activities.create(activity)
|
||||
|
||||
if project_activity.new_record?
|
||||
raise ActiveRecord::Rollback, "Overridding TimeEntryActivity was not successfully saved"
|
||||
else
|
||||
self.time_entries.update_all("activity_id = #{project_activity.id}", ["activity_id = ?", parent_activity.id])
|
||||
self.time_entries.
|
||||
where(["activity_id = ?", parent_activity.id]).
|
||||
update_all("activity_id = #{project_activity.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue