excid3 / noticed

Notifications for Ruby on Rails applications
MIT License
2.4k stars 169 forks source link

Unclear section in the upgrade guide about polymorphic record association #425

Closed drjole closed 6 months ago

drjole commented 6 months ago

In my opinion, the upgrade guide is unclear about how to migrate related records to the new database schema. In particular, it is about this section from Noticed 2.0 > Models:

# Extract related record to `belongs_to :record` association
# This allows ActiveRecord associations instead of querying the JSON data
# attributes[:record] = params.delete(:user) || params.delete(:account)

The params variable is not defined anywhere else in this code block and it would be clearer if it just said attribute[:params] which is the correct thing to use in this case instead of what I used first (notification.params) which does not contain the deserialized record.