-
Notifications
You must be signed in to change notification settings - Fork 336
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
missing keyword: :coder If no default coder is configured, a coder must be provided to serialize
. rails 7
#382
Comments
serialize
.serialize
. rails 7
This is holding us back from upgrading to Rails 7.1. Does anyone have a solution? |
How did this pass testing? |
Looks like it needs to be changed to something like (default coder was previously YAML)
|
Running into this. Could use some enlightenment on the cause and any workarounds that might deal with it? Thanks! |
@crustyratfink PR seems to be in the works (#384), but if I'm reading the code right, there should be a way to add "parameters" as a column type and override this. So perhaps if you include this line of code in the model, it might work. I don't think I actually use this gem (I work on a number of projects with clients, and some of those include Heroku stack upgrades that require resolving issues like this); I just came across it with the same error I was getting, and passed the fix along so others could handle it.
|
+1 to this, its holding us back from bumping to 7.1. |
If you take a closer look at https://github.com/public-activity/public_activity#rails-7 you’ll notice the following:
So in the current release Rails 7.1 is only partially supported in that one has to either monkey patch |
@santosh-1987 @jeffcovey @MyklClason @samy-at-shopify I’ve implemented the same fix as provided in #384 weeks ago but initially that broke a few tests and rightly so! As it stands, I’ll have to reject the PR. The issue is that it only works with Rails 7.1+ but our support matrix is much wider than that. Thankfully, it’s straight forward to make it work of In the meantime, you have the following 2 options, though I haven’t tried either of them:
I had to permit the following classes for one of my apps but YMMV: Alternatively, you can just wait a few more days for the next release as mentioned above. |
@santosh-1987 @jeffcovey @MyklClason @samy-at-shopify I was wrong about the compatibility, s. my comment. @MyklClason you were right. |
Regression introduced in #5012e0d6. This change partially reverts the change such that it works for Rails 6.1/7.0 and 7.1+. In Rails 7.1+ the API for `.serialize` changed. At first using `serialize :parameters, coder: YAML, type: Hash` seems to be backwards compatible with Rails 6.1/7.0 when reading the documentation/code but there’s a subtle difference: when the 2nd positional parameter (denoting the target type) is not provided a default mechanism is used. While the defaults will use `YAML` as the coder the serialization will only occur if the column is not `NULL`. So, without an explicit type parameter `nil`/`NULL` values are not converted to `Hash`. Thus, the explicit type parameter acts as the fallback for the value itself. Fixes #386 #384 #382
For those ending up here that have the same issue with rpush for instance, doing:
in |
If your column need json serializer class Example < ApplicationRecord
class_attribute :default_column_serializer, instance_accessor: false, default: ::ActiveRecord::Coders::JSON
end This will also fix rpush serializer issue in rails > 7 with ruby > 3 |
The text was updated successfully, but these errors were encountered: