Skip to content

Commit 9d6a8b3

Browse files
committed
Include Rack::MethodOverride middleware for API only apps
Otherwise POST requests with _method set to something else won't work.
1 parent d6764c7 commit 9d6a8b3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ And that's it. With this alone, you should be able to access Mission Control Job
3030

3131
![Failed jobs tab in a simple app](docs/images/failed-jobs-simple.png)
3232

33-
### API-only apps or apps using `vite_rails`
33+
### API-only apps or apps using `vite_rails` and other asset pipelines outside Rails
3434

35-
If you want to use Mission Control – Jobs with an [API-only Rails app](https://guides.rubyonrails.org/api_app.html) or an app that's using `vite_ruby`/`vite_rails`, you need just one more thing: configure an asset pipeline so you can serve the JavaScript and CSS included in this gem. We recommend to use [`propshaft`](https://github.com/rails/propshaft). You simply need to add this line to your application's Gemfile:
35+
If you want to use this gem with an [API-only Rails app](https://guides.rubyonrails.org/api_app.html) or an app that's using `vite_ruby`/`vite_rails`, or some other custom asset pipeline different from Sprockets and Propshaft, you need just one more thing: configure an asset pipeline so you can serve the JavaScript and CSS included in this gem. We recommend to use [`Propshaft`](https://github.com/rails/propshaft). You simply need to add this line to your application's Gemfile:
3636

3737
```ruby
3838
gem "propshaft"

lib/mission_control/jobs/engine.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ module Jobs
77
class Engine < ::Rails::Engine
88
isolate_namespace MissionControl::Jobs
99

10-
config.middleware.use ActionDispatch::Flash unless config.action_dispatch.flash
10+
initializer "mission_control-jobs.middleware" do |app|
11+
if app.config.api_only
12+
app.middleware.use ActionDispatch::Flash
13+
app.middleware.use ::Rack::MethodOverride
14+
end
15+
end
1116

1217
config.mission_control = ActiveSupport::OrderedOptions.new unless config.try(:mission_control)
1318
config.mission_control.jobs = ActiveSupport::OrderedOptions.new

0 commit comments

Comments
 (0)