Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recur_tasks: NoMethodError: undefined method `default_status' #71

Closed
rufinus opened this issue May 4, 2015 · 3 comments
Closed

recur_tasks: NoMethodError: undefined method `default_status' #71

rufinus opened this issue May 4, 2015 · 3 comments
Assignees
Labels
Milestone

Comments

@rufinus
Copy link

rufinus commented May 4, 2015

Any idea how to solve this?

Redmine: 2.6.4
RecurringTasks: a331d49

$ bundle exec rake RAILS_ENV=production redmine:recur_tasks
Checking for Redmine recurring tasks.
rake aborted!
NoMethodError: undefined method `default_status' for #<Tracker:0x000000046fa5f0>
/srv/www/redmine/vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.21/lib/active_model/attribute_methods.rb:407:in `method_missing'
/srv/www/redmine/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.21/lib/active_record/attribute_methods.rb:149:in `method_missing'
/srv/www/redmine/plugins/recurring_tasks/app/models/recurring_task.rb:252:in `recur_issue_if_needed!'
/srv/www/redmine/plugins/recurring_tasks/app/models/recurring_task.rb:284:in `block in add_recurrences!'
/srv/www/redmine/plugins/recurring_tasks/app/models/recurring_task.rb:283:in `each'
/srv/www/redmine/plugins/recurring_tasks/app/models/recurring_task.rb:283:in `add_recurrences!'
/srv/www/redmine/plugins/recurring_tasks/lib/tasks/recurring_tasks.rake:12:in `block (2 levels) in <top (required)>'
Tasks: TOP => redmine:recur_tasks
(See full trace by running task with --trace)

TIA

@jmfarina
Copy link

jmfarina commented May 5, 2015

Hello, I bumped on the same issue today and I've solved it this way.
I couldn't find info on the default_status field, but it seems that the initialization of the issue's status was changed as part of contributed changes to make the plugin compatible with Redmine 3.0.
I don't have a working Redmine 3.0 to test this, but if I'm not mistaken, with this patch it should work in either case.

diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb
index 8dc7c68..d1da90e 100644
--- a/app/models/recurring_task.rb
+++ b/app/models/recurring_task.rb
@@ -249,7 +249,11 @@
       new_issue.due_date = next_scheduled_recurrence #41 previous_date_for_recurrence + recurrence_pattern
       new_issue.start_date = new_issue.due_date
       new_issue.done_ratio = 0
-      new_issue.status = issue.tracker.default_status # issue status is NOT automatically new, default is whatever the default status for new issues is
+      if issue.tracker.respond_to?(:default_status)
+        new_issue.status = issue.tracker.default_status # issue status is NOT automatically new, default is whatever the default status for new issues is
+      else
+        new_issue.status = IssueStatus.default # issue status is NOT automatically new, default is whatever the default status for new issues is
+      end
       new_issue.save!
       puts "Recurring #{issue.id}: #{issue.subj_date}, created #{new_issue.id}: #{new_issue.subj_date}"

@rufinus
Copy link
Author

rufinus commented May 5, 2015

@jmfarina thanks, your fix is working.

@devaroop
Copy link

devaroop commented Jun 9, 2015

same problem. Thanks for the fix!

@nutso nutso added this to the Redmine 3 milestone Jun 14, 2015
@nutso nutso added the bug label Jun 14, 2015
@nutso nutso self-assigned this Jun 14, 2015
@nutso nutso closed this as completed Jun 14, 2015
@nutso nutso mentioned this issue Jun 14, 2015
@nutso nutso added this to the v1.5.0 milestone Jun 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants