herokupaperclipruby-on-rails-5turbolinks-5

Rails 5 on heroku forgets files stored with paperclip and turbolinks: No route matches


I have a blog with file up-/download via paperclip 5.1.0 and turbolinks 5.0.1. Upload without validation works fine now, but download is only working for a short period after upload. Afterwards an error (404) is displayed:

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

If you are the application owner check the logs for more information.

This did not help:

heroku rake db:migrate
heroku restart

I am on production with mysql DB on heroku. When I am not deploying via heroku: then the local copy works just fine with ruby version 2.2.4!

New deployment on heroku with git push heroku master does not fix the attachment links.

Only manual deletion of DB files and new upload makes attachment links work again for a short period of time.

P. S. When the dyno is restartet, e. g. with heroku restart, then the filesystem is new and deleted. But I do not know, how to make filesystem persistent with redis or amazon aws s3!

The log says:

2017-01-31T12:21:03.027810+00:00 heroku[router]: at=info method=GET path="/system/articles/attachments/000/000/015/original/gmr-1.8.3.jar" host=infinite-taiga-25466.herokuapp.com request_id=fb775bcc-64f4-4d6b-89c0-70991af31e2f fwd="178.15.12.47" dyno=web.1 connect=0ms service=2ms status=404 bytes=1744 2017-01-31T12:21:03.026812+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] Started GET "/system/articles/attachments/000/000/015/original/gmr-1.8.3.jar" for 178.15.12.47 at 2017-01-31 12:21:03 +0000 2017-01-31T12:21:03.027262+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] 2017-01-31T12:21:03.027284+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] ActionController::RoutingError (No route matches [GET] "/system/articles/attachments/000/000/015/original/gmr-1.8.3.jar"): 2017-01-31T12:21:03.027302+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] 2017-01-31T12:21:03.027334+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/debug_exceptions.rb:53:in call' 2017-01-31T12:21:03.027336+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/show_exceptions.rb:31:incall' 2017-01-31T12:21:03.027337+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/rack/logger.rb:36:in call_app' 2017-01-31T12:21:03.027338+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:inblock in call' 2017-01-31T12:21:03.027339+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/tagged_logging.rb:26:in tagged' 2017-01-31T12:21:03.027338+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/tagged_logging.rb:69:inblock in tagged' 2017-01-31T12:21:03.027340+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/tagged_logging.rb:69:in tagged' 2017-01-31T12:21:03.027341+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:incall' 2017-01-31T12:21:03.027341+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/request_id.rb:24:in call' 2017-01-31T12:21:03.027342+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/method_override.rb:22:incall' 2017-01-31T12:21:03.027343+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/runtime.rb:22:in call' 2017-01-31T12:21:03.027344+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall' 2017-01-31T12:21:03.027345+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/executor.rb:12:in call' 2017-01-31T12:21:03.027346+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/actionpack-5.0.1/lib/action_dispatch/middleware/static.rb:136:incall' 2017-01-31T12:21:03.027346+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in call' 2017-01-31T12:21:03.027347+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/railties-5.0.1/lib/rails/engine.rb:522:incall' 2017-01-31T12:21:03.027349+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/puma-3.7.0/lib/puma/server.rb:578:in handle_request' 2017-01-31T12:21:03.027349+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/puma-3.7.0/lib/puma/server.rb:415:inprocess_client' 2017-01-31T12:21:03.027350+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/puma-3.7.0/lib/puma/server.rb:275:in block in run' 2017-01-31T12:21:03.027351+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/puma-3.7.0/lib/puma/thread_pool.rb:120:incall' 2017-01-31T12:21:03.027352+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/puma-3.7.0/lib/puma/thread_pool.rb:120:in block in spawn_thread' 2017-01-31T12:21:03.027348+00:00 app[web.1]: [fb775bcc-64f4-4d6b-89c0-70991af31e2f] vendor/bundle/ruby/2.2.0/gems/puma-3.7.0/lib/puma/configuration.rb:226:incall'

C:\Sites\blog_production_heroku>


Solution

  • New git version of paperclip gem now works with aws-sdk-s3 gem, add this to Gemfile:

    #Paperclip
    gem 'paperclip', git: 'git://github.com/thoughtbot/paperclip.git'