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

Move controller helper method into model and call with safe navigation... #23616

Merged
merged 1 commit into from Jul 11, 2018

Conversation

aoby
Copy link
Contributor

@aoby aoby commented Jul 10, 2018

…operator to prevent null error

See https://app.honeybadger.io/projects/3240/faults/38563701#notice-summary
This user has an old enrollment for a workshop which was deleted (on 2017-01-06).

NoMethodError: undefined method `subject' for nil:NilClass[PROJECT_ROOT]/app/controllers/api/v1/pd/workshops_controller.rb:257 :in `future_or_current_teachercon_or_fit?`

future_or_current_teachercon_or_fit?(enrollment.workshop)
end
enrollments = ::Pd::Enrollment.for_user(current_user).all.reject do |enrollment|
enrollment.workshop&.future_or_current_teachercon_or_fit?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this is needed - workshops delete their enrollments when they are deleted. Do we know what happened here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This is surprising. Perhaps an anomaly, from some manual intervention?

The models in question are enrollment id 1460 (created 2016-06-21), and workshop id 292 (created 2016-06-21, deleted 2017-01-06).

@aoby aoby merged commit 48793ac into staging Jul 11, 2018
@aoby aoby deleted the workshop-nil-check branch July 11, 2018 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants