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.
|
# does not successfully save.
|
||||||
def create_time_entry_activity_if_needed(activity)
|
def create_time_entry_activity_if_needed(activity)
|
||||||
if activity['parent_id']
|
if activity['parent_id']
|
||||||
|
|
||||||
parent_activity = TimeEntryActivity.find(activity['parent_id'])
|
parent_activity = TimeEntryActivity.find(activity['parent_id'])
|
||||||
activity['name'] = parent_activity.name
|
activity['name'] = parent_activity.name
|
||||||
activity['position'] = parent_activity.position
|
activity['position'] = parent_activity.position
|
||||||
|
|
||||||
if Enumeration.overridding_change?(activity, parent_activity)
|
if Enumeration.overridding_change?(activity, parent_activity)
|
||||||
project_activity = self.time_entry_activities.create(activity)
|
project_activity = self.time_entry_activities.create(activity)
|
||||||
|
|
||||||
if project_activity.new_record?
|
if project_activity.new_record?
|
||||||
raise ActiveRecord::Rollback, "Overridding TimeEntryActivity was not successfully saved"
|
raise ActiveRecord::Rollback, "Overridding TimeEntryActivity was not successfully saved"
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue