You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: posts/2025-08-01-watch-out-for-this-one-deprecation-warning-when-upgrading-from-rails-7-dot-1-to-7-dot-2-on-heroku.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,14 +25,17 @@ The deprecation warning was:
25
25
[DEPRECATION] DEPRECATIONWARNING:`Rails.application.secrets` is deprecated
26
26
in favor of `Rails.application.credentials`and will be removed inRails7.2.
27
27
```
28
+
We moved all the secrets and encrypted secrets to the credentials file.
29
+
30
+
We also moved the `secret_key_base` to credentials because it's the default place for this secret since introduction of the credentials feature in Rails 5.2.
28
31
29
32
We removed values from `ENV["SECRET_KEY_BASE"]` to credentials and checked that the value was correct by calling
30
33
`Rails.application.credentials.secret_key_base`.
31
34
32
35
It turned out that you can also get the secret_key_base by calling `Rails.application.secret_key_base`.
33
36
34
37
35
-
Let's take a look at this code:
38
+
Let's take a look at this code:
36
39
37
40
```ruby
38
41
defsecret_key_base
@@ -52,11 +55,11 @@ Ok so to sum it up, until now:
52
55
53
56
Right? But instead...
54
57
55
-
Instead it failed silently. So where’s the poop?
58
+
Instead it failed silently. **All the cookies become invalid**. So where’s the poop?
The poop is in Heroku trying to be smarter than developers. Unfortunately. It turned out that removing `SECRET_KEY_BASE` env leads to.. regenerating it with new **random** value.
62
+
The poop is in Heroku trying to be smarter than developers. Unfortunately. It turned out that removing `SECRET_KEY_BASE` env leads to... regenerating it with new **random** value.
60
63
61
64
So our external devices depending on it couldn’t work because of new, randomly generated key.
62
65
@@ -65,5 +68,5 @@ To sum it up:
65
68
- If you’re getting rid of the `Rails.application.secrets` is deprecated in favor of `Rails.application.credentials` and will be removed in Rails 7.2
66
69
- And you’re on Heroku
67
70
- And you’re using Heroku Buildpacks
68
-
- Make sure you keep `SECRET_KEY_BASE` in both credentials and in Heroku ENV variable
71
+
- Make sure you keep `SECRET_KEY_BASE` in both credentials and in Heroku config variable. Or at least in the latter.
69
72
- Either way... you may end up in nasty silent error. Which is not good.
0 commit comments