我在rails上的ruby上有一个实用程序,可以将文件上传到公共文件夹。通过提供该文件的链接,我可以下载该文件。
它在本地rails服务器上正常工作。
我将我的工作部署到了heroku。上传部分的工作原理。但是当我点击登录按钮时,它只是给出了错误
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
在查看heroku日志时,我发现这是一个路由错误。
任何人请让我知道我错过了什么。因为我真的是初学者。
谢谢你,
更新 这是heroku日志
2014-08-12T12:44:02.705737+00:00 app[web.1]: Rendered internships/show.html.erb within layouts/application (23.2ms)
2014-08-12T12:44:14.260997+00:00 heroku[router]: at=info method=GET path="/resume/Saghir%20Resume1.docx" host=shielded-atoll-2450.herokuapp.com request_id=87d911ee-2bb3-40e7-923b-a8029f7ab6ff fwd="39.44.84.14" dyno=web.1 connect=2ms service=27ms status=404 bytes=1182
2014-08-12T12:44:14.253695+00:00 app[web.1]: Started GET "/resume/Saghir%20Resume1.docx" for 39.44.84.14 at 2014-08-12 12:44:14 +0000
2014-08-12T12:44:14.256004+00:00 app[web.1]:
2014-08-12T12:44:14.253706+00:00 app[web.1]: Started GET "/resume/Saghir%20Resume1.docx" for 39.44.84.14 at 2014-08-12 12:44:14 +0000
2014-08-12T12:44:14.256011+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2014-08-12T12:44:14.256016+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2014-08-12T12:44:14.256007+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/resume/Saghir%20Resume1.docx"):
2014-08-12T12:44:14.256009+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.5/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2014-08-12T12:44:14.256014+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/rack/logger.rb:20:in `block in call'
2014-08-12T12:44:14.256017+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/tagged_logging.rb:26:in `tagged'
2014-08-12T12:44:14.256012+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/rack/logger.rb:38:in `call_app'
2014-08-12T12:44:14.256056+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2014-08-12T12:44:14.256059+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
2014-08-12T12:44:14.256054+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/application.rb:97:in `call'
2014-08-12T12:44:14.256022+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.5/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2014-08-12T12:44:14.256063+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
2014-08-12T12:44:14.256019+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/tagged_logging.rb:68:in `tagged'
2014-08-12T12:44:14.256020+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/rack/logger.rb:20:in `call'
2014-08-12T12:44:14.256064+00:00 app[web.1]:
2014-08-12T12:44:14.256060+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
2014-08-12T12:44:14.256078+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/rack/logger.rb:20:in `block in call'
2014-08-12T12:44:14.256066+00:00 app[web.1]:
2014-08-12T12:44:14.256057+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
2014-08-12T12:44:14.256094+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/engine.rb:511:in `call'
2014-08-12T12:44:14.256023+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2014-08-12T12:44:14.256077+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/rack/logger.rb:38:in `call_app'
2014-08-12T12:44:14.256072+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/resume/Saghir%20Resume1.docx"):
2014-08-12T12:44:14.256074+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.5/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2014-08-12T12:44:14.256090+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
2014-08-12T12:44:14.256080+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2014-08-12T12:44:14.256098+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
2014-08-12T12:44:14.256091+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.5/lib/action_dispatch/middleware/static.rb:64:in `call'
2014-08-12T12:44:14.256025+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2014-08-12T12:44:14.256104+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
2014-08-12T12:44:14.256027+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
2014-08-12T12:44:14.256097+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2014-08-12T12:44:14.256085+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.5/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2014-08-12T12:44:14.256095+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/application.rb:97:in `call'
2014-08-12T12:44:14.256102+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2014-08-12T12:44:14.256083+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/tagged_logging.rb:68:in `tagged'
答案 0 :(得分:1)
您的链接是/resume/Saghir%20Resume1.docx
(/resume/Saghir Resume1.docx
),但您在公共文件夹中说它是上传目录/public/resume/file_name
?你是否将Rails设置为serve_static_assets
?
正如@CodeGnome
指出的那样,Heroku是一个短暂的文件系统,所以整个方法都是一个坏主意 - 通常你会为你上传的文件使用Amazon S3或类似的文件存储。即使您的路线正确,您上传的文件也可以使用不同的动态,因为您运行的是多个,或者因为您已重新部署。
答案 1 :(得分:1)
Heroku有一个叫做Ephemeral文件系统的东西,所以在dyno的生命周期中它的运行进程可以使用它,但是这里存储的任何文件都会在dyno完成后被丢弃,所以是的它会保存文件,但之后它已删除,因此无法找到它。
一种非常常见的方法是使用paperclip和Amazon S3来处理/存储上传,这些也非常简单。这是一篇很好的文章,解释了如何执行此操作:https://devcenter.heroku.com/articles/paperclip-s3