Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6aa1fc6

Browse files
committed
Finalize rails 7.0 config defaults
1 parent 5d2a6e3 commit 6aa1fc6

File tree

7 files changed

+41
-149
lines changed

7 files changed

+41
-149
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ gem 'css_parser', '= 1.10.0' # pinned because we use private methods
1818
gem 'rb-readline'
1919

2020
# Image processing
21-
gem 'image_processing', '~> 1.12.2'
21+
gem 'image_processing', '~> 1.13.0'
2222

2323
gem 'rss', '~> 0.3.1'
2424

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ GEM
132132
activesupport (>= 6.1)
133133
i18n (1.14.7)
134134
concurrent-ruby (~> 1.0)
135-
image_processing (1.12.2)
135+
image_processing (1.13.0)
136136
mini_magick (>= 4.9.5, < 5)
137137
ruby-vips (>= 2.0.17, < 3)
138138
jbuilder (2.13.0)
@@ -315,7 +315,7 @@ DEPENDENCIES
315315
css_parser (= 1.10.0)
316316
devise (~> 4.9.4)
317317
dotenv-rails (= 2.7.6)
318-
image_processing (~> 1.12.2)
318+
image_processing (~> 1.13.0)
319319
jbuilder (~> 2.5)
320320
kaminari (~> 1.2.1)
321321
letter_opener (~> 1.7.0)

app/controllers/posts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def process_new_audio(image) ## Image model used for all media
161161
## takes a saved Image object, returns the markdown content to refer to the image
162162
def process_new_image(image)
163163
blob_path = path_for(image.blob)
164-
image_meta = ActiveStorage::Analyzer::ImageAnalyzer.new(image.blob).metadata
164+
image_meta = ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick.new(image.blob).metadata
165165
if image_meta[:width] > 1600 #resize at lower quality with link
166166
return "\n\n<a href=\"#{image_path(image)}\">\n <img src=\"#{image_resized_path(image)}\"></img>\n</a>"
167167
else #simple full image

config/application.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
module Blog
2222
class Application < Rails::Application
2323
# Initialize configuration defaults for originally generated Rails version.
24-
config.load_defaults 6.1
24+
config.load_defaults 7.0
2525

2626
# Configuration for the application, engines, and railties goes here.
2727
#
@@ -30,5 +30,9 @@ class Application < Rails::Application
3030
#
3131
# config.time_zone = "Central Time (US & Canada)"
3232
# config.eager_load_paths << Rails.root.join("extras")
33+
34+
## from migration to Rails version 7.0.x
35+
#config.active_support.cache_format_version = 7.0
36+
#config.active_support.disable_to_s_conversion = true
3337
end
3438
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html#key-generator-digest-class-changing-to-use-sha256
2+
Rails.application.config.after_initialize do
3+
Rails.application.config.action_dispatch.cookies_rotations.tap do |cookies|
4+
authenticated_encrypted_cookie_salt = Rails.application.config.action_dispatch.authenticated_encrypted_cookie_salt
5+
signed_cookie_salt = Rails.application.config.action_dispatch.signed_cookie_salt
6+
7+
secret_key_base = Rails.application.secret_key_base
8+
9+
key_generator = ActiveSupport::KeyGenerator.new(
10+
secret_key_base, iterations: 1000, hash_digest_class: OpenSSL::Digest::SHA1
11+
)
12+
key_len = ActiveSupport::MessageEncryptor.key_len
13+
14+
old_encrypted_secret = key_generator.generate_key(authenticated_encrypted_cookie_salt, key_len)
15+
old_signed_secret = key_generator.generate_key(signed_cookie_salt)
16+
17+
cookies.rotate :encrypted, old_encrypted_secret
18+
cookies.rotate :signed, old_signed_secret
19+
end
20+
end

config/initializers/cookies_serializer.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@
22

33
# Specify a serializer for the signed and encrypted cookie jars.
44
# Valid options are :json, :marshal, and :hybrid.
5-
Rails.application.config.action_dispatch.cookies_serializer = :json
5+
6+
# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
7+
# is `:marshal`. The default for new apps is `:json`.
8+
#
9+
# To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
10+
#
11+
# Rails transparently deserializes existing (Marshal-serialized) cookies on read and
12+
# re-writes them in the JSON format.
13+
#
14+
# It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
15+
# have been converted to JSON.
16+
Rails.application.config.action_dispatch.cookies_serializer = :hybrid

config/initializers/new_framework_defaults_7_0.rb

Lines changed: 0 additions & 143 deletions
This file was deleted.

0 commit comments

Comments
 (0)