我有一个博客,通过paperclip 5.1.0和turbolinks 5.0.1进行文件上传/下载。没有验证的上传工作正常,但下载仅在上传后的短时间内有效。之后会显示错误(404):
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.
这没有帮助:
heroku rake db:migrate
heroku restart
我正在使用heroku上的mysql DB进行制作。当我没有通过heroku进行部署时:本地副本在ruby 2.2.4版本上运行得很好!
使用git push heroku master
在heroku上进行的新部署无法修复附件链接。
只有手动删除数据库文件和新上传才能使附件链接在短时间内再次运行。
P上。 S.当dyno重新启动时,e。 G。使用heroku restart
,然后文件系统是新的并删除。但我不知道,如何使用redis或amazon aws s3使文件系统持久化!
日志说:
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]开始获取“/ 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(没有路由匹配[GET]“/ system / articles / attachments / 000/000/015 /原厂/ 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:in
call'
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:in
阻止通话'
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:in
阻止标记为'
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:in
调用'
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:in
call'
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:in
来电'
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: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 / 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:in
来电'
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:in
process_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:in
来电'
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:in
调用'
C:\网站\ blog_production_heroku>
答案 0 :(得分:0)
这是根本原因:
当dyno定期重启或使用heroku restart
时,文件系统初始化为新的。
我仍在努力将Amazon S3持久性添加到我的应用中......
答案 1 :(得分:0)
新的git版本的回形针gem现在可以与aws-sdk-s3 gem一起使用,并将其添加到Gemfile中:
#Paperclip
gem 'paperclip', git: 'git://github.com/thoughtbot/paperclip.git'