Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

No such middleware to insert before: ActionDispatch::Static #12

Closed
brunogh opened this Issue · 7 comments

3 participants

@brunogh

After I changed "config.serve_static_assets" to false, I started to get the error below when I try to push to Heroku.

Not sure if it is related to http://stackoverflow.com/questions/7824570/heroku-conflict-between-gzipping-assets-and-precompiling-assets

No such middleware to insert before: ActionDispatch::Static
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/stack.rb:119:in assert_index'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.12/lib/action_dispatch/middleware/stack.rb:83:in
insert'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/configuration.rb:38:in block in merge_into'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/configuration.rb:37:in
each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/configuration.rb:37:in merge_into'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/engine.rb:446:in
app'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application/finisher.rb:37:in block in <module:Finisher>'
/tmp/build_35d88t67t7z0x/config/application.rb:112:in
instance_exec'
/tmp/build_35d88t67t7z0x/config/application.rb:112:in run'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:55:in
block in run_initializers'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:54:in each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/initializable.rb:54:in
run_initializers'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application.rb:96:in initialize!'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/railtie/configurable.rb:30:in
method_missing'
/tmp/build_35d88t67t7z0x/config/environment.rb:129:in <top (required)>'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in
require'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in block in require'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:223:in
block in load_dependency'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:640:in new_constants_in'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:223:in
load_dependency'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in require'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application.rb:83:in
require_environment!'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/railties-3.1.12/lib/rails/application.rb:203:in block (2 levels) in initialize_tasks'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in
call'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in block in execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in
each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in
block in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in
invoke'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.12/lib/sprockets/assets.rake:89:in block (2 levels) in <top (required)>'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in
call'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in block in execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in
each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in
block in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:205:in
block in invoke_prerequisites'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:203:in each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:203:in
invoke_prerequisites'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:183:in block in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in
invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in invoke'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.12/lib/sprockets/assets.rake:56:in
block (3 levels) in '
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in call'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in
block in execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in
execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in block in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in
invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in invoke'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.12/lib/sprockets/assets.rake:19:in
invoke_or_reboot_rake_task'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.12/lib/sprockets/assets.rake:25:in block (2 levels) in <top (required)>'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in
call'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in block in execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in
each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in execute'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in
block in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in invoke_with_call_chain'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in
invoke'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in invoke_task'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in
block (2 levels) in top_level'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in each'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in
block in top_level'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in run_with_threads'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in
top_level'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in block in run'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in
standard_exception_handling'
/tmp/build_35d88t67t7z0x/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'

Thanks.

@romanbsd
Owner

Why would you turn it off?

@brunogh

Thanks Roman. I will not serve with Heroku, but with Cloudfront (CDN) acessing Heroku.

Actually I was facing some weird problem... when cache is enabled (through config.cache_store = :dalli_store), seems that Heroku is responding always without gzip. If I remove that cache, it works, however I cant do that because it is used by the app.

I though that setting "config.serve_static_assets" to false might work, but read that Heroku overrides that config to true.

Not sure if I am doing correctly.

@romanbsd
Owner

Is it possible to set cloudfront accessing heroku without the serve_static_assets? Or you're precompiling and putting the assets to S3 yourself?
To put it another way - I don't know a way to work with heroku without serve_static_assets, therefore the middleware is inserted exactly before it.

@brunogh

Hi Roman,

Thanks.

What I am trying to do is Cloudfront -> Heroku assets

I was discussing this approach on another thread (rumblelabs/asset_sync#153 (comment)) and seems that gzip was not working correctly due to Rack::Cache. I have already set "serve_static_assets" to true again, because that was not the problem.

So I am trying to put Rack::Cache after HerokuDeflater::SkipBinary and HerokuDeflater::ServeZippedAssets middleware, but I cannot see them listed when type "rake middleware". Not sure why did not work.

I am testing on staging and this gem (heroku-deflater) is on this group.

@brunogh

Just noticed that I am running with and old version of heroku-deflater since it depends on rack 1.4.5 and I am using Rails 3.1.17. Sorry.

@Lordnibbler

@brunogh ever get this resolved? I am still experiencing this issue when deploying to Heroku with Rails 4

@brunogh

I end up with not using the gem and also using Rails 3.2.

I am using Cloudfront accessing Heroku, so added CompressedStaticAssets file to my project and then changed Rack in production to:

require "#{config.root}/lib/compressed_static_assets"
config.middleware.insert_before "Rack::Cache", ::Middleware::CompressedStaticAssets, paths["public"].first, config.assets.prefix, { 'Cache-Control' => "public, max-age=31536000" }
@romanbsd romanbsd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.