I have a sample page I'm working on:
http://os-oven.herokuapp.com/
where I started uploading pictures for products. At some point during my trying things out, I had to run
heroku restart
which wiped out my pictures:
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>'
The pictures must have been saved locally, and when I restarted my app, it pulled the latest code from git.
How do I persist product pictures in the database for spree?
My thoughts:
Put them in something like s3. Downside to this is I would rather have a 'free-er' option for now. Plus, how would you configure spree to do this?
Get the files in version control. This may work, except I would need prod and dev to use the same db with the same file paths stored in the db.
Persist blobs to the db. I know this is probably not the most efficient way, but the data would always be available. Still would have to tweak the spree engine to do this.
You can't save picture on heroku.
Heroku has "Read-only Filesystem" https://devcenter.heroku.com/articles/read-only-filesystem
For free you can use cloudinary.com or Amazon S3
Amazon S3 also free up to 5Gb. http://aws.amazon.com/free/
Related
I've deployed my Rails app running Puma on Heroku. I am using the gem websockets-rails for live chat and notifications.
I've had some issues connecting to websockets (RuntimeError (eventmachine not initialized: evma_install_oneshot_timer):) initially but I fixed that by adding
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
to a config/initializers/eventmachine.rb. Again, everything works fine locally when I run heroku local and doesn't timeout/become eventmachine not initialized after a few minutes.
However, every time I deploy/re-deploy on Heroku, WebSockets works fine for the first few minutes but fails afterwards. I get a WebSocket connection to 'wss://www.studbuds.com/websocket' failed: Error during WebSocket handshake: Unexpected response code: 500 error on the client-side and the stack trace
2016-01-20T17:59:12.672733+00:00 app[web.1]: RuntimeError (eventmachine not initialized: evma_install_oneshot_timer):
2016-01-20T17:59:12.672734+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:331:in `add_oneshot_timer'
2016-01-20T17:59:12.672735+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:331:in `add_timer'
2016-01-20T17:59:12.672735+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/eventmachine-1.0.8/lib/em/timers.rb:50:in `schedule'
2016-01-20T17:59:12.672736+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/eventmachine-1.0.8/lib/em/timers.rb:37:in `initialize'
2016-01-20T17:59:12.672736+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_adapters.rb:167:in `new'
2016-01-20T17:59:12.672737+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_adapters.rb:167:in `start_ping_timer'
2016-01-20T17:59:12.672738+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_adapters.rb:46:in `initialize'
2016-01-20T17:59:12.672739+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_adapters/web_socket.rb:10:in `initialize'
2016-01-20T17:59:12.672739+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_adapters.rb:14:in `new'
2016-01-20T17:59:12.672740+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_adapters.rb:14:in `establish_connection'
2016-01-20T17:59:12.672741+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_manager.rb:78:in `open_connection'
2016-01-20T17:59:12.672741+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/websocket-rails-0.7.0/lib/websocket_rails/connection_manager.rb:55:in `call'
2016-01-20T17:59:12.672742+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/mapper.rb:51:in `serve'
2016-01-20T17:59:12.672742+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:43:in `block in serve'
2016-01-20T17:59:12.672743+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:30:in `each'
2016-01-20T17:59:12.672743+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:30:in `serve'
2016-01-20T17:59:12.672744+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:819:in `call'
2016-01-20T17:59:12.672744+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.4/lib/warden/manager.rb:35:in `block in call'
2016-01-20T17:59:12.672745+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.4/lib/warden/manager.rb:34:in `catch'
2016-01-20T17:59:12.672745+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.4/lib/warden/manager.rb:34:in `call'
2016-01-20T17:59:12.672746+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
2016-01-20T17:59:12.672747+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in `call'
2016-01-20T17:59:12.672747+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
2016-01-20T17:59:12.672748+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2016-01-20T17:59:12.672748+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/flash.rb:260:in `call'
2016-01-20T17:59:12.672748+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
2016-01-20T17:59:12.672749+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
2016-01-20T17:59:12.672749+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/cookies.rb:560:in `call'
2016-01-20T17:59:12.672749+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/query_cache.rb:36:in `call'
2016-01-20T17:59:12.672750+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in `call'
2016-01-20T17:59:12.672751+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2016-01-20T17:59:12.672751+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88:in `call'
2016-01-20T17:59:12.672751+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88:in `_run_callbacks'
2016-01-20T17:59:12.672752+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
2016-01-20T17:59:12.672752+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
2016-01-20T17:59:12.672752+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2016-01-20T17:59:12.672753+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
2016-01-20T17:59:12.672753+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2016-01-20T17:59:12.672753+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2016-01-20T17:59:12.672757+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:38:in `call_app'
2016-01-20T17:59:12.672757+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `block in call'
2016-01-20T17:59:12.672758+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2016-01-20T17:59:12.672758+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:26:in `tagged'
2016-01-20T17:59:12.672758+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:68:in `tagged'
2016-01-20T17:59:12.672759+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/rack/logger.rb:20:in `call'
2016-01-20T17:59:12.672759+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/request_store-1.3.0/lib/request_store/middleware.rb:9:in `call'
2016-01-20T17:59:12.672760+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2016-01-20T17:59:12.672760+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
2016-01-20T17:59:12.672761+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
2016-01-20T17:59:12.672761+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
2016-01-20T17:59:12.672762+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/static.rb:113:in `call'
2016-01-20T17:59:12.672762+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
2016-01-20T17:59:12.672762+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/ssl.rb:24:in `call'
2016-01-20T17:59:12.672763+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:518:in `call'
2016-01-20T17:59:12.672763+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:164:in `call'
2016-01-20T17:59:12.672764+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'
2016-01-20T17:59:12.672765+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/puma-2.15.3/lib/puma/server.rb:541:in `handle_request'
2016-01-20T17:59:12.672765+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/puma-2.15.3/lib/puma/server.rb:388:in `process_client'
2016-01-20T17:59:12.672766+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/puma-2.15.3/lib/puma/server.rb:270:in `block in run'
2016-01-20T17:59:12.672766+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/puma-2.15.3/lib/puma/thread_pool.rb:106:in `call'
2016-01-20T17:59:12.672766+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/puma-2.15.3/lib/puma/thread_pool.rb:106:in `block in spawn_thread'
If I restart the dynos, it works again but dies shortly after.
Note I'm use a Puma which is multi-threaded, so could it be that my application is not thread-safe?
Thaks for helping.
I'm developing an app in ruby on rails hosted in heroku
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
This is what i get in heroku logs:
2014-11-16T00:34:45.183714+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/rack/logger.rb:20:in `block in call'
2014-11-16T00:34:45.183727+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
2014-11-16T00:34:45.183740+00:00 app[web.1]:
2014-11-16T00:34:45.182107+00:00 app[web.1]: Started GET "/home/search?q=todas+las+ganas+y+mi+entusiasmo&entity_subtype=userpoint&entity_type=object&search_type=entities" for 188.165.15.198 at 2014-11-16 00:34:45 +0000
2014-11-16T00:34:45.183681+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:68:in `tagged'
2014-11-16T00:34:45.183694+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2014-11-16T00:34:45.183710+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2014-11-16T00:34:45.183723+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2014-11-16T00:34:45.183736+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2014-11-16T00:34:46.112900+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:26:in `tagged'
2014-11-16T00:34:46.112917+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
I tryed migrating the db in heroku but i get this error:
Running rake db:migrate attached to terminal... failed
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: connect timeout reached (Excon::Errors::Timeout)
Backtrace: /Users/felipevelasquez/.heroku/client/vendor/gems/excon-0.40.0/lib/excon/ssl_socket.rb:124:in `rescue in initialize'
/Users/felipevelasquez/.heroku/client/vendor/gems/excon-0.40.0/lib/excon/ssl_socket.rb:105:in `initialize'
/Users/felipevelasquez/.heroku/client/vendor/gems/excon-0.40.0/lib/excon/connection.rb:380:in `new'
/Users/felipevelasquez/.heroku/client/vendor/gems/excon-0.40.0/lib/excon/connection.rb:380:in `socket'
/Users/felipevelasquez/.heroku/client/vendor/gems/excon-0.40.0/lib/excon/connection.rb:105:in `request_call'
I don't know how to identify the error in heroku.
Ideas?
try
heroku run bundle
to have your dependencies in place.
I have a utility on ruby on rails that uploads files to public folder. And by providing the link to that file i can download that file.
It is working fine on local rails server.
I deployed my work to heroku. where uploading part works. but when i click to login button it simply gives error
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
on looking to heroku logs, i noticed it is a routing error.
Any one please let me know what i am missing. as i am really beginner with heroku.
Thanks regards,
Update
Here are the heroku logs
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'
Your link is to /resume/Saghir%20Resume1.docx (/resume/Saghir Resume1.docx) but you say its in the public folder -- is the upload directory /public/resume/file_name? And are you set for Rails to serve_static_assets?
As #CodeGnome pointed out, Heroku is an ephemeral filesystem so the entire approach is a bad idea -- typically you'd use Amazon S3 or a similar filestore for your uploaded files. Even if your routes are right, the file you uploaded can be on a different dyno because you're running more than one or because you've redeployed.
Heroku has something called the Ephemeral filesystem, so during the dyno’s lifetime its running processes can make use of it, but any file stored here will be discarded after the dyno has finished, so yes it does save the file, but after that it is deleted so it won't find it.
A very common approach is using paperclip and Amazon S3 for handling/storing the uploads, and those are pretty straightforward to install too. Here is a great article explaining how to do so: https://devcenter.heroku.com/articles/paperclip-s3
I have deployed my application to Heroku and forked the environment to create a 'staging' environment. I copied my paroduction.rb file to create a staging.rb, but when I change the RAILS_ENV and RACK_ENV variables from production to staging no assets are returned and the logs show the following type errors:
2014-05-05T07:42:33.614170+00:00 app[web.1]: F, [2014-05-05T07:42:33.610206 #2] FATAL -- :
2014-05-05T07:42:33.614172+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/application-835271b3bd7cf8b176e8b30d9ca395fd.js"):
2014-05-05T07:42:33.614173+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2014-05-05T07:42:33.614174+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2014-05-05T07:42:33.614176+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/rack/logger.rb:38:in `call_app'
2014-05-05T07:42:33.614177+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/rack/logger.rb:20:in `block in call'
2014-05-05T07:42:33.614178+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2014-05-05T07:42:33.614200+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:26:in `tagged'
2014-05-05T07:42:33.614202+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/tagged_logging.rb:68:in `tagged'
2014-05-05T07:42:33.614203+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/rack/logger.rb:20:in `call'
2014-05-05T07:42:33.614204+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.4/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2014-05-05T07:42:33.614206+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2014-05-05T07:42:33.614207+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2014-05-05T07:42:33.614218+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.4/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
2014-05-05T07:42:33.614219+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
2014-05-05T07:42:33.614221+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/engine.rb:511:in `call'
2014-05-05T07:42:33.614222+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.4/lib/rails/application.rb:97:in `call'
2014-05-05T07:42:33.614224+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2014-05-05T07:42:33.614225+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-05-05T07:42:33.614226+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-05-05T07:42:33.614228+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
2014-05-05T07:42:33.614229+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2014-05-05T07:42:33.614231+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
I have found other posts on Stackoverflow e.g.: ActionController::RoutingError (No route matches [GET] "/assets/images/control_top.png"): in rails 3.2.8
and indeed changing config.serve_static_assets = false to true solves the problem, but I am reluctant to do this in just my staging environment and I understand that this will affect performance within the production environment.
What I really do not understand is why this error is occurring when the only difference as far as I can tell is that the environment variable names are changed. So to my question:
What does changing these environment variables actually change about the application? Why does it have this effect in my application?
As a bonus if there is a better way to solve the underlying problem I have described to have staging mirroring the production config I would appreciate the guidance.
Further investigation has established that the setting of environment variables has the following effect within deployment:
The environment-specific configuration files (such as config/environments/production.rb)
installation of gems as defined within the Gemfile group (e.g. group :production)
In this case heroku requires the gem 'rails_12factor' to enable static assets to be served. Therefore in addition to the group :production this gem is required for :staging.
I have been working on an app locally for a while now, and I've matched my development environment to that on Heroku as closely as I can.
The app is set up for multi-tenancy using Apartment (https://github.com/influitive/apartment), and designed to use subdomains to identify tenants. Both environments use postgres, and Apartment has been using schemas to manage the 'tanants' data.
This evening, I have attempted to push the code to Heroku (the same app before it became multi-tenancy worked beautifully), and no pages load, all give an error.
I've taken a look at the logs, and the most interesting line I can find is; Apartment::SchemaNotFound (One of the following schema(s) is invalid: heroku-app-name, "public"):
This certainly seems to be a peculiarity of Heroku, but I'm struggling for ideas on where to look next.
Any suggestions or help would be appreciated.
I've included all of the logs for reference;
2014-04-04T18:27:09.884367+00:00 app[web.1]: Apartment::SchemaNotFound (One of the following schema(s) is invalid: heroku-app-name, "public"):
2014-04-04T18:27:09.884368+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/adapters/postgresql_adapter.rb:95:in `rescue in connect_to_new'
2014-04-04T18:27:09.884384+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
2014-04-04T18:27:09.884362+00:00 app[web.1]:
2014-04-04T18:27:09.884385+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
2014-04-04T18:27:09.884364+00:00 app[web.1]: I, [2014-04-04T18:27:09.879482 #2] INFO -- : Started GET "/favicon.ico" for 92.25.163.224 at 2014-04-04 18:27:09 +0000
2014-04-04T18:27:09.884388+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2014-04-04T18:27:09.884389+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/flash.rb:241:in `call'
2014-04-04T18:27:09.884366+00:00 app[web.1]: F, [2014-04-04T18:27:09.884136 #2] FATAL -- :
2014-04-04T18:27:09.884370+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/adapters/postgresql_adapter.rb:88:in `connect_to_new'
2014-04-04T18:27:09.884381+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
2014-04-04T18:27:09.884371+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/adapters/abstract_adapter.rb:100:in `switch'
2014-04-04T18:27:09.884383+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
2014-04-04T18:27:09.884396+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
2014-04-04T18:27:09.884372+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/apartment-0.24.3/lib/apartment/elevators/generic.rb:20:in `call'
2014-04-04T18:27:09.884387+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2014-04-04T18:27:09.884398+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2014-04-04T18:27:09.884403+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
2014-04-04T18:27:09.884391+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
2014-04-04T18:27:09.884392+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
2014-04-04T18:27:09.884399+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__2212192162733263500__call__callbacks'
2014-04-04T18:27:09.884400+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
2014-04-04T18:27:09.884393+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/cookies.rb:486:in `call'
2014-04-04T18:27:09.884402+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2014-04-04T18:27:09.884406+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2014-04-04T18:27:09.884379+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
2014-04-04T18:27:09.884395+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/query_cache.rb:36:in `call'
2014-04-04T18:27:09.884409+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/rack/logger.rb:21:in `block in call'
2014-04-04T18:27:09.884407+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/rack/logger.rb:38:in `call_app'
2014-04-04T18:27:09.884410+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67:in `block in tagged'
2014-04-04T18:27:09.884404+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2014-04-04T18:27:09.884430+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67:in `tagged'
2014-04-04T18:27:09.884431+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/rack/logger.rb:21:in `call'
2014-04-04T18:27:09.884432+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2014-04-04T18:27:09.884428+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:25:in `tagged'
2014-04-04T18:27:09.884435+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
2014-04-04T18:27:09.884444+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call'
2014-04-04T18:27:09.884434+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2014-04-04T18:27:09.884437+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
2014-04-04T18:27:09.884442+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call'
2014-04-04T18:27:09.884445+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
2014-04-04T18:27:09.884448+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-04-04T18:27:09.884446+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-04-04T18:27:09.884450+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
2014-04-04T18:27:09.884451+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2014-04-04T18:27:09.884452+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
Take a look at your apartment initializer and remove the subdomain elevator settings. i commented out everything related to elevator. since your app is probably on a heroku subdomain, the elevator setting will try to load that particular tenant from the db and will issue that error.
it worked fine for me after i commented
# Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'