{"action":"created","issue":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/23462","repository_url":"https://api.github.com/repos/code-dot-org/code-dot-org","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/23462/labels{/name}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/23462/comments","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/23462/events","html_url":"https://github.com/code-dot-org/code-dot-org/pull/23462","id":337609066,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NzQ4NjU0","number":23462,"title":"WIP Teacher Feedback - Dependent destroy","user":{"login":"epeach","id":2959170,"node_id":"MDQ6VXNlcjI5NTkxNzA=","avatar_url":"https://avatars0.githubusercontent.com/u/2959170?v=4","gravatar_id":"","url":"https://api.github.com/users/epeach","html_url":"https://github.com/epeach","followers_url":"https://api.github.com/users/epeach/followers","following_url":"https://api.github.com/users/epeach/following{/other_user}","gists_url":"https://api.github.com/users/epeach/gists{/gist_id}","starred_url":"https://api.github.com/users/epeach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epeach/subscriptions","organizations_url":"https://api.github.com/users/epeach/orgs","repos_url":"https://api.github.com/users/epeach/repos","events_url":"https://api.github.com/users/epeach/events{/privacy}","received_events_url":"https://api.github.com/users/epeach/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-02T17:52:21Z","updated_at":"2018-07-02T18:21:33Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/23462","html_url":"https://github.com/code-dot-org/code-dot-org/pull/23462","diff_url":"https://github.com/code-dot-org/code-dot-org/pull/23462.diff","patch_url":"https://github.com/code-dot-org/code-dot-org/pull/23462.patch"},"body":"Per discussions with Poorva, if a teacher is deleted, we want to delete the feedback they have provided.\r\n\r\nNote: Tests incoming"},"comment":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments/401891443","html_url":"https://github.com/code-dot-org/code-dot-org/pull/23462#issuecomment-401891443","issue_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/23462","id":401891443,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTg5MTQ0Mw==","user":{"login":"aoby","id":8405316,"node_id":"MDQ6VXNlcjg0MDUzMTY=","avatar_url":"https://avatars0.githubusercontent.com/u/8405316?v=4","gravatar_id":"","url":"https://api.github.com/users/aoby","html_url":"https://github.com/aoby","followers_url":"https://api.github.com/users/aoby/followers","following_url":"https://api.github.com/users/aoby/following{/other_user}","gists_url":"https://api.github.com/users/aoby/gists{/gist_id}","starred_url":"https://api.github.com/users/aoby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aoby/subscriptions","organizations_url":"https://api.github.com/users/aoby/orgs","repos_url":"https://api.github.com/users/aoby/repos","events_url":"https://api.github.com/users/aoby/events{/privacy}","received_events_url":"https://api.github.com/users/aoby/received_events","type":"User","site_admin":false},"created_at":"2018-07-02T18:21:33Z","updated_at":"2018-07-02T18:21:33Z","author_association":"CONTRIBUTOR","body":"Yes, in a way. The association itself needs to be only based on the [teacher_id](https://github.com/code-dot-org/code-dot-org/blob/staging/dashboard/app/models/teacher_feedback.rb#L9) in TeacherFeedbacks, not the `student_id`. There is nothing special to add to the `dependent_destroy` but the association needs to be fixed. By default the `has_many` association assumes the foreign key in the associated model is based on the class name where it's defined. In other words, this is looking for `teacher_feedbacks.user_id`, which does not exist.\r\n\r\nIt should be defined as:\r\n```ruby\r\nhas_many :teacher_feedbacks, foreign_key: 'teacher_id', dependent: :destroy\r\n```\r\n\r\nAnd add a unit test to make sure it works."}}
{"actor":{"display_login":"aoby"}}