Skip to content

Commit

Permalink
fix: add betters support for api-only applications, fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
hschne committed Aug 1, 2021
1 parent 40fd81b commit 6e8f77b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Expand Up @@ -221,6 +221,28 @@ rails rails_mini_profiler:install:migrations
rails db:migrate
```

### Support for API-Only Apps

Rails Mini Profiler supports API-only apps, but you have to make some small adjustments to use it. At the top of `application.rb` add [Sprockets](https://github.com/rails/sprockets-rails):

```
require "sprockets/railtie"
```

Then, modify `application.rb`:

```
module ApiOnly
class Application < Rails::Application
config.api_only = true # Either set this to false
config.middleware.use ActionDispatch::Flash # Or add this
end
end
```

**Note: Sprockets and flash are currently required for some of Rails Mini Profiler's UI features. These modifications may no longer be needed in the future.

### Flamegraphs are not rendering?

Flamegraphs are loaded into [Speedscope](https://github.com/jlfwong/speedscope) using an Iframe and URI Encoded blobs (see [source](https://github.com/hschne/rails-mini-profiler/blob/main/app/views/rails_mini_profiler/flamegraphs/show.html.erb))
Expand Down
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module RailsMiniProfiler
class ApplicationController < ::ApplicationController
class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, with: :not_found

before_action :check_current_user
Expand Down

0 comments on commit 6e8f77b

Please sign in to comment.