File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -91,14 +91,21 @@ serialize :parameters, Hash
9191
9292so we instead switch to serializing as JSON:
9393``` ruby
94+ # Rails 5.2/6.0
9495serialize :parameters , JSON
96+ # Rails 6.1+
97+ serialize :parameters , type: Hash , coder: JSON
9598```
9699
97100If 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
101106serialize :parameters , Hash
107+ # Rails 6.1+ (untested, might not work!)
108+ serialize :parameters , type: Hash , coder: Hash
102109```
103110
104111In addition, one of the following is also needed.
Original file line number Diff line number Diff 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 ]
Original file line number Diff line number Diff line change 1+ ---
12test :
23 adapter : sqlite3
34 database : db/combustion_test.sqlite
You can’t perform that action at this time.
0 commit comments