Skip to content

Commit 50ec5e7

Browse files
committed
🐛 Fix Rails 5.2 and 6.0 support
1 parent 2ff45b8 commit 50ec5e7

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,21 @@ serialize :parameters, Hash
9191

9292
so we instead switch to serializing as JSON:
9393
```ruby
94+
# Rails 5.2/6.0
9495
serialize :parameters, JSON
96+
# Rails 6.1+
97+
serialize :parameters, type: Hash, coder: JSON
9598
```
9699

97100
If an implementation needs to continue using the serialized Hash,
98-
you will need to override the definition by reopening the model, and adding:
101+
you will need to override the definition by reopening the model,
102+
and set it back to the old way!
99103

100104
```ruby
105+
# Rails 5.2/6.0
101106
serialize :parameters, Hash
107+
# Rails 6.1+ (untested, might not work!)
108+
serialize :parameters, type: Hash, coder: Hash
102109
```
103110

104111
In addition, one of the following is also needed.

app/models/masq/open_id_request.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ class OpenIdRequest < ActiveRecord::Base
44

55
before_validation :make_token, on: :create
66

7-
serialize :parameters, type: Hash, coder: JSON
7+
if Rails.gem_version >= Gem::Version.create("6.1")
8+
serialize :parameters, type: Hash, coder: JSON
9+
else # Rails 5.2 & 6.0
10+
serialize :parameters, JSON
11+
end
812

913
def parameters
1014
self[:parameters]

test/internal/config/database.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
test:
23
adapter: sqlite3
34
database: db/combustion_test.sqlite

0 commit comments

Comments
 (0)