Skip to content

Commit debebe6

Browse files
authored
Fix compatibility with Rails 8.2 (#19)
- Fix `undefined method 'detach_from' for class ActionController::LogSubscriber (NoMethodError)`. - Set minimum Rails to 7.0; Update CI matrix.
1 parent 4a840ae commit debebe6

10 files changed

Lines changed: 35 additions & 29 deletions

File tree

.github/workflows/documentation-coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818
- uses: ruby/setup-ruby@v1
1919
with:
20-
ruby-version: "3.3"
20+
ruby-version: "3.4"
2121
bundler-cache: true
2222

2323
- name: Validate coverage

.github/workflows/documentation.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
runs-on: ubuntu-latest
2626

2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v6
2929

3030
- uses: ruby/setup-ruby@v1
3131
with:
32-
ruby-version: "3.3"
32+
ruby-version: "3.4"
3333
bundler-cache: true
3434

3535
- name: Installing packages
@@ -40,7 +40,7 @@ jobs:
4040
run: bundle exec bake utopia:project:static --force no
4141

4242
- name: Upload documentation artifact
43-
uses: actions/upload-pages-artifact@v3
43+
uses: actions/upload-pages-artifact@v4
4444
with:
4545
path: docs
4646

.github/workflows/rubocop.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1717
- uses: ruby/setup-ruby@v1
1818
with:
1919
ruby-version: ruby

.github/workflows/test-coverage.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ jobs:
2222

2323
ruby:
2424
- "3.3"
25+
- "3.4"
2526

2627
steps:
27-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v6
2829
- uses: ruby/setup-ruby@v1
2930
with:
3031
ruby-version: ${{matrix.ruby}}
@@ -34,7 +35,7 @@ jobs:
3435
timeout-minutes: 5
3536
run: bundle exec bake test
3637

37-
- uses: actions/upload-artifact@v3
38+
- uses: actions/upload-artifact@v5
3839
with:
3940
name: coverage-${{matrix.os}}-${{matrix.ruby}}
4041
path: .covered.db
@@ -44,13 +45,13 @@ jobs:
4445
runs-on: ubuntu-latest
4546

4647
steps:
47-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v6
4849
- uses: ruby/setup-ruby@v1
4950
with:
50-
ruby-version: "3.3"
51+
ruby-version: "3.4"
5152
bundler-cache: true
5253

53-
- uses: actions/download-artifact@v3
54+
- uses: actions/download-artifact@v5
5455

5556
- name: Validate coverage
5657
timeout-minutes: 5

.github/workflows/test-external.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ jobs:
2020
- macos
2121

2222
ruby:
23-
- "3.1"
24-
- "3.2"
25-
- "3.3"
23+
- "3.4"
2624

2725
steps:
28-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v6
2927
- uses: ruby/setup-ruby@v1
3028
with:
3129
ruby-version: ${{matrix.ruby}}

.github/workflows/test.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ jobs:
2121
- macos
2222

2323
ruby:
24-
- "3.1"
25-
- "3.2"
2624
- "3.3"
25+
- "3.4"
2726

2827
gemfile:
29-
- gems/rails-v6.rb
3028
- gems/rails-v7.rb
29+
- gems/rails-v8.rb
3130

3231
experimental: [false]
3332

@@ -46,7 +45,7 @@ jobs:
4645
BUNDLE_GEMFILE: ${{matrix.gemfile}}
4746

4847
steps:
49-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v6
5049
- uses: ruby/setup-ruby@v1
5150
with:
5251
ruby-version: ${{matrix.ruby}}

console-adapter-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
2626

2727
spec.add_dependency "console", "~> 1.21"
2828
spec.add_dependency "fiber-storage", "~> 1.0"
29-
spec.add_dependency "rails", ">= 6.1"
29+
spec.add_dependency "rails", ">= 7.0"
3030
end

gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
gem "bake-test"
2424
gem "bake-test-external"
2525

26-
gem "sqlite3", "~> 1.4"
26+
gem "sqlite3", ">= 1.4"
2727
end

gems/rails-v6.rb renamed to gems/rails-v8.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
eval_gemfile('../gems.rb')
77

8-
gem 'rails', '~> 6.0'
8+
gem 'rails', '~> 8.0'

lib/console/adapter/rails/railtie.rb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,31 @@ class Railtie < ::Rails::Railtie
1515
initializer 'console.adapter.rails', before: :initialize_logger do |app|
1616
# 1. Set up Console to be used as the Rails logger
1717
Logger.apply!(configuration: app.config)
18-
18+
1919
# 2. Remove the Rails::Rack::Logger middleware as it also doubles up on request logs
2020
app.middleware.delete ::Rails::Rack::Logger
2121
end
22-
22+
2323
# 3. Remove existing log subscribers for ActionController and ActionView
2424
config.after_initialize do
25-
::ActionController::LogSubscriber.detach_from :action_controller
26-
25+
if ::ActionController::LogSubscriber < ::ActiveSupport::LogSubscriber
26+
::ActionController::LogSubscriber.detach_from :action_controller
27+
else
28+
::ActiveSupport.event_reporter.unsubscribe(::ActionController::LogSubscriber)
29+
end
30+
2731
# Silence the default action view logs, e.g. "Rendering text template" etc
28-
::ActionView::LogSubscriber.detach_from :action_view
32+
if ::ActionView::LogSubscriber < ::ActiveSupport::LogSubscriber
33+
::ActionView::LogSubscriber.detach_from :action_view
34+
else
35+
::ActiveSupport.event_reporter.unsubscribe(::ActionView::LogSubscriber)
36+
end
2937
end
30-
38+
3139
config.after_initialize do
3240
# 4. Add a new log subscriber for ActionController
3341
ActionController.apply!
34-
42+
3543
# 5. (optionally) Add a new log subscriber for ActiveRecord
3644
# ActiveRecord.apply!
3745
end

0 commit comments

Comments
 (0)