Actions
Defect #32537
openRake taks works on redmine 3.4 but does not work on 4 while for Redmine 4 it works in console
Status:
New
Priority:
Normal
Assignee:
-
Category:
Custom fields
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Affected version:
Description
I have described problem here:
So, same code works in console on Redmine 4, and on Redmine 3.4 it works well in both console and as rake task.
On Redmine 4, as rake task, it says "saved" but no actual database change occured.
Updated by Aleksandar Pavic almost 6 years ago
Eventually I was able to make the following code work with Redmine 4
namespace :redmine do
namespace :myplugin do
desc 'Updates custom field for idle tickets.'
task :update_idle => :environment do
Issue.open.each do |issue|
begin
days = DateTime.now.to_time - DateTime.parse(issue.updated_on.to_s).to_time
days = days/86400
if days > 0
issue.custom_values.each do |x|
if x.custom_field_id == 19
x.value = days.ceil
x.save
end
end
issue.save
true
end
end
end
end
end
end
But I still think above described behavior is bug...
Updated by Go MAEDA almost 5 years ago
Could you try again after changing all save method to save! method?
save! thorows an exception when it fails. Probably it is useful to troubleshoot this issue.
Actions