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:
Toshi MARUYAMA 2014-01-10 12:49:20 +00:00
parent 1c71eccff2
commit 073b403bd9
1 changed files with 3 additions and 4 deletions

View File

@ -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