Closed ivanyv closed 3 years ago
hello @ivanyv please try to clone repo and connect in your app and try if it works you can try to make a PR or I'll make a fix. I just want to know if this is a working solution
@ivanyv how you are disabling this setting? how to reproduce
@igorkasyanchuk in config/environments/X.rb
, config.serve_static_files = false
I've in all apps
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
and this RAILS_SERVE_STATIC_FILES is not present
so I think it's false by default.
I'm asking because maybe you have some code where you are deleting middleware.
and this options is explicitly false in prod config.
There could be that some library is removing that middleware but I'm not doing it explicitly. FWIW, setting that config to true fixes the issue (forgot to mention this is Rails 4.2).
try the new version, it has new features plus I've added a fix for your problem
gem 'rails_performance', '1.0.0.beta5'
Will do, thanks!
does it work? @ivanyv
new version released, I think now should work
@igorkasyanchuk sorry it took me a bit to look at this again; it doesn't work yet because the middleware insertion happens later, so I think a better solution could be:
after = app.config.serve_static_files ? ActionDispatch::Static : Rack::SendFile
app.middleware.insert_after after, RailsPerformance::Rails::Middleware
@ivanyv is right. Still produces an error.
@ivanyv @salzig please it someone can create a PR it would be nice. I just can't handle it now. Thank you
In such case,
ActionDispatch::Static
does not exist, causing an exception in https://github.com/igorkasyanchuk/rails_performance/blob/master/lib/rails_performance/engine.rb#L16.Not sure if conditionally using
Rack::Sendfile
when appropriate or usinginsert_before Rack::Lock
would make more sense.