Destroy all related TODOs when removing a user
Summary
When a user with related TODOs is destroyed, the TODOs dashboard containing those TODOs results in a 500 Internal Server Error. This is due to do todos table referencing an author id of a user that does not exist any longer. This problem seems to be very similar to the one described in #14095 (closed).
Started GET "/dashboard/todos" for 127.0.0.1 at 2016-03-09 16:16:34 +0000
Processing by Dashboard::TodosController#index as HTML
Completed 500 Internal Server Error in 110ms (ActiveRecord: 10.9ms)
ActionView::Template::Error (undefined method `downcase' for nil:NilClass):
1: %li{class: "todo todo-#{todo.done? ? 'done' : 'pending'}", id: dom_id(todo) }
2: .todo-item{class: 'todo-block'}
3: = image_tag avatar_icon(todo.author_email, 40), class: 'avatar s40', alt:''
4:
5: .todo-title
6: %span.author_name
app/helpers/application_helper.rb:75:in `avatar_icon'
app/views/dashboard/todos/_todo.html.haml:3:in `_app_views_dashboard_todos__todo_html_haml__1817795895220069161_48848220'
app/views/dashboard/todos/index.html.haml:51:in `block in _app_views_dashboard_todos_index_html_haml___4054721272558586193_58065100'
app/views/dashboard/todos/index.html.haml:44:in `each'
app/views/dashboard/todos/index.html.haml:44:in `_app_views_dashboard_todos_index_html_haml___4054721272558586193_58065100'
Affected Version
8.5.4-ce