Skip to content

Refactor invitation and workshop sponsor handling#2483

Open
mroderick wants to merge 6 commits intocodebar:masterfrom
mroderick:stop-using-update-attribute
Open

Refactor invitation and workshop sponsor handling#2483
mroderick wants to merge 6 commits intocodebar:masterfrom
mroderick:stop-using-update-attribute

Conversation

@mroderick
Copy link
Collaborator

@mroderick mroderick commented Feb 15, 2026

I started looking for outdated/deprecated Rails code in the repository.

update_attribute was at the top of that list according to the LLM I used ... though I do still see it in the API docs.

In any case, I think the code reads a lot better this way.

Summary

Replaces all 22 occurrences of deprecated update_attribute (removed in Rails 7.0+) with semantic model methods.

Changes

  • New model methods:

    • WorkshopInvitation#accept! / decline! - Workshop RSVP management
    • MeetingInvitation#accept! / decline! - Meeting RSVP management
    • Invitation#accept! / decline! / verify! - Event invitation management
    • WorkshopSponsor#set_as_host! / remove_as_host! - Sponsor host management
  • Safety improvements:

    • Adds global ActiveRecord::RecordInvalid handler in ApplicationController
    • Wraps waitlist promotion in transaction to prevent race conditions
  • Technical change: Uses update! instead of update_attribute - validations now run (behavioral improvement from silent failures to explicit errors)

Context

Based on the deprecated Rails practices analysis in docs/deprecated-rails-practices-report.md, this addresses the highest-priority issue: the 23 occurrences of update_attribute (22 in code, 1 in historical migration).

Files Changed

  • 4 models: WorkshopInvitation, MeetingInvitation, Invitation, WorkshopSponsor
  • 3 controllers: InvitationsController, InvitationControllerConcerns, Admin::SponsorConcerns
  • ApplicationController (error handler)
  • 11 spec files (updated to use new model methods)

Testing

All tests pass. Model methods include unit tests for validation behavior.

Replaces update_attribute usage with semantic methods that run validations.
- accept!(rsvp_time:, automated_rsvp:) - confirms attendance with timestamp
- decline! - cancels attendance

Both methods use update! and raise RecordInvalid on validation failures.
Includes unit tests.
Adds semantic methods for RSVP management with validation support.
- accept! - confirms meeting attendance
- decline! - cancels meeting attendance

Includes unit tests.
Adds methods for event invitation management:
- accept!(verified:) - confirms attendance with optional pre-verification
- verify! - marks attendance as verified
- decline! - cancels event attendance

Includes unit tests.
Adds methods for managing sponsor host status:
- set_as_host! - designates sponsor as workshop host
- remove_as_host! - removes host designation

Includes unit tests.
@mroderick mroderick force-pushed the stop-using-update-attribute branch from 4a72e7d to cc0c2fa Compare February 15, 2026 12:19
Replaces update_attribute calls in controllers and specs with new model methods:
- InvitationsController: use accept!, verify!, decline!
- InvitationControllerConcerns: use decline! with transaction wrapper
- Admin::SponsorConcerns: use set_as_host!, remove_as_host!
@mroderick mroderick force-pushed the stop-using-update-attribute branch from cc0c2fa to c4a4ae8 Compare February 15, 2026 12:27
@mroderick mroderick marked this pull request as ready for review February 15, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant