在&heroku restart'之后坚持狂欢产品图片。

时间:2015-01-08 14:18:00

标签: ruby-on-rails git heroku spree

我有一个我正在处理的示例页面:

http://os-oven.herokuapp.com/

我开始上传产品图片。在我尝试的时候,我必须运行

heroku restart

摧毁了我的照片:

2015-01-08T14:13:39.161552+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/spree/products/1/small/Pumpkin_Pie_from_a_-real-_pumpkin__November_2007.jpg"):
2015-01-08T14:13:39.161554+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2015-01-08T14:13:39.161555+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2015-01-08T14:13:39.161573+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:38:in `call_app'
2015-01-08T14:13:39.161574+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `block in call'
2015-01-08T14:13:39.161576+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2015-01-08T14:13:39.161578+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:26:in `tagged'
2015-01-08T14:13:39.161579+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `tagged'
2015-01-08T14:13:39.161581+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `call'
2015-01-08T14:13:39.161582+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2015-01-08T14:13:39.161584+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2015-01-08T14:13:39.161585+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2015-01-08T14:13:39.161586+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
2015-01-08T14:13:39.161588+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/static.rb:84:in `call'
2015-01-08T14:13:39.161590+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
2015-01-08T14:13:39.161591+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/engine.rb:514:in `call'
2015-01-08T14:13:39.161593+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
2015-01-08T14:13:39.161594+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in `process_client'
2015-01-08T14:13:39.161596+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop'
2015-01-08T14:13:39.161597+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
2015-01-08T14:13:39.161598+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
2015-01-08T14:13:39.161600+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
2015-01-08T14:13:39.161601+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
2015-01-08T14:13:39.161602+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<main>'

图片必须已在本地保存,当我重新启动应用程序时,它会从git中提取最新代码。

如何将数据库中的产品图片保存为狂欢?

我的想法:

  1. 把它们放在像s3这样的东西上。在这方面的缺点是我宁愿拥有一个“自由”的人。现在的选择。另外,如何配置spree来执行此操作?
  2. 获取版本控制中的文件。这可能有用,除了我需要prod和dev使用相同的db与db中存储的相同文件路径。
  3. 坚持blob到数据库。我知道这可能不是最有效的方式,但数据总是可用的。仍然需要调整狂欢引擎才能做到这一点。

1 个答案:

答案 0 :(得分:1)

您无法在heroku上保存图片。 Heroku拥有&#34;只读文件系统&#34; https://devcenter.heroku.com/articles/read-only-filesystem

免费使用cloudinary.com或Amazon S3 亚马逊S3还可以免费提供5Gb。 http://aws.amazon.com/free/