如何解决在部署到Heroku时出现500状态的问题

huangapple go评论60阅读模式
英文:

How to resolve 500 status when deploying to Heroku

问题

2023-02-15T20:31:47.060556+00:00 app[web.1]: I, [2023-02-15T20:31:47.060491 #2] INFO --: [f8806da7-4389-4a8f-b176-19ed6c60103f] 开始GET请求"/users/sign_up",来自IP地址66.249.64.84,时间为2023年2月15日20:31:47 +0000
2023-02-15T20:31:47.061344+00:00 app[web.1]: I, [2023-02-15T20:31:47.061287 #2] INFO --: [f8806da7-4389-4a8f-b176-19ed6c60103f] 正在处理RegistrationsController#new的GET请求,返回HTML格式
2023-02-15T20:31:47.062452+00:00 app[web.1]: D, [2023-02-15T20:31:47.062413 #2] DEBUG --: [f8806da7-4389-4a8f-b176-19ed6c60103f] (0.1毫秒) 查询sqlite版本
2023-02-15T20:31:47.062848+00:00 app[web.1]: I, [2023-02-15T20:31:47.062814 #2] INFO --: [f8806da7-4389-4a8f-b176-19ed6c60103f] 完成500内部服务器错误,耗时1毫秒(ActiveRecord: 0.3毫秒 | 分配: 527)
2023-02-15T20:31:47.063561+00:00 app[web.1]: F, [2023-02-15T20:31:47.063527 #2] FATAL --: [f8806da7-4389-4a8f-b176-19ed6c60103f]
2023-02-15T20:31:47.063561+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] ActiveRecord::StatementInvalid (无法找到表'users'):
2023-02-15T20:31:47.063562+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f]
2023-02-15T20:31:47.063562+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:346:in 'table_structure'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in 'columns'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:112:in 'columns'

英文:
2023-02-15T20:31:47.060556+00:00 app[web.1]: I, [2023-02-15T20:31:47.060491 #2]  INFO -- : [f8806da7-4389-4a8f-b176-19ed6c60103f] Started GET "/users/sign_up" for 66.249.64.84 at 2023-02-15 20:31:47 +0000
2023-02-15T20:31:47.061344+00:00 app[web.1]: I, [2023-02-15T20:31:47.061287 #2]  INFO -- : [f8806da7-4389-4a8f-b176-19ed6c60103f] Processing by RegistrationsController#new as HTML
2023-02-15T20:31:47.062452+00:00 app[web.1]: D, [2023-02-15T20:31:47.062413 #2] DEBUG -- : [f8806da7-4389-4a8f-b176-19ed6c60103f]    (0.1ms)  SELECT sqlite_version(*)
2023-02-15T20:31:47.062848+00:00 app[web.1]: I, [2023-02-15T20:31:47.062814 #2]  INFO -- : [f8806da7-4389-4a8f-b176-19ed6c60103f] Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.3ms | Allocations: 527)
2023-02-15T20:31:47.063561+00:00 app[web.1]: F, [2023-02-15T20:31:47.063527 #2] FATAL -- : [f8806da7-4389-4a8f-b176-19ed6c60103f]
2023-02-15T20:31:47.063561+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] ActiveRecord::StatementInvalid (Could not find table 'users'):
2023-02-15T20:31:47.063562+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f]
2023-02-15T20:31:47.063562+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:346:in `table_structure'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `columns'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:112:in `block in columns'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:111:in `fetch'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:111:in `columns'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:120:in `block in columns_hash'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:119:in `fetch'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:119:in `columns_hash'
2023-02-15T20:31:47.063565+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:553:in `load_schema!'
2023-02-15T20:31:47.063566+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/attributes.rb:250:in `load_schema!'
2023-02-15T20:31:47.063566+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:539:in `block in load_schema'
2023-02-15T20:31:47.063566+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:536:in `synchronize'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:536:in `load_schema'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:402:in `attribute_types'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/attribute_methods.rb:187:in `_has_attribute?'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/inheritance.rb:57:in `new'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] devise (4.8.1) lib/devise/models/registerable.rb:22:in `new_with_session'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] devise (4.8.1) app/controllers/devise/registrations_controller.rb:100:in `build_resource'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] devise (4.8.1) app/controllers/devise/registrations_controller.rb:10:in `new'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/base.rb:228:in `process_action'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
2023-02-15T20:31:47.063569+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
2023-02-15T20:31:47.063569+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
2023-02-15T20:31:47.063569+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actiontext (6.1.7.2) lib/action_text/rendering.rb:20:in `with_renderer'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actiontext (6.1.7.2) lib/action_text/engine.rb:59:in `block (4 levels) in <class:Engine>'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:126:in `instance_exec'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:137:in `run_callbacks'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
2023-02-15T20:31:47.063573+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
2023-02-15T20:31:47.063573+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
2023-02-15T20:31:47.063573+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/notifications.rb:203:in `block in instrument'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/notifications.rb:203:in `instrument'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/base.rb:165:in `process'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionview (6.1.7.2) lib/action_view/rendering.rb:39:in `process'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal.rb:190:in `dispatch'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal.rb:254:in `dispatch'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/route_set.rb:33:in `serve'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/mapper.rb:49:in `serve'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/journey/router.rb:50:in `block in serve'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/journey/router.rb:32:in `each'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/journey/router.rb:32:in `serve'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/route_set.rb:842:in `call'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/deflater.rb:44:in `call'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] warden (1.2.9) lib/warden/manager.rb:34:in `catch'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] warden (1.2.9) lib/warden/manager.rb:34:in `call'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/tempfile_reaper.rb:15:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/etag.rb:27:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/conditional_get.rb:27:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/head.rb:12:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/http/content_security_policy.rb:19:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/session/abstract/id.rb:266:in `context'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/session/abstract/id.rb:260:in `call'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/cookies.rb:697:in `call'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:98:in `run_callbacks'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/rack/logger.rb:37:in `call_app'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/rack/logger.rb:26:in `block in call'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/tagged_logging.rb:99:in `block in tagged'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/tagged_logging.rb:37:in `tagged'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/tagged_logging.rb:99:in `tagged'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/rack/logger.rb:26:in `call'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/request_id.rb:26:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/method_override.rb:24:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/runtime.rb:22:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/static.rb:24:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/sendfile.rb:110:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/ssl.rb:77:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/engine.rb:539:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/configuration.rb:228:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/server.rb:727:in `handle_request'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/server.rb:476:in `process_client'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/server.rb:332:in `block in run'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/thread_pool.rb:134:in `block in spawn_thread'

Ruby app was previously on Heroku-18 stack and deprecated a few months ago. I upgraded to Heroku-22 stack on yesterday and have not had any success being able to login or sign up to the app. The app successfully deploys to Heroku and I can access the homepage but when I navigate to enter information to be stored in the database I receive the, "We're sorry, but something went wrong", error.

When I run the Heroku logs command I receive the above print out for the logs. I've updated the ruby gem version and rails version on the app as well.

I'm not sure how to fix/correct the issues?

答案1

得分: 0

看起来您的应用程序配置为使用SQLite作为数据库适配器,并且没有找到数据库。由于Heroku的临时文件系统(除非它是只读数据库),使用SQLite肯定不会起作用。

相反,最常见且最有文档支持的选项是使用Heroku PostgreSQL数据库,可以将其添加为附加组件。或者,还有其他许多数据库附加组件可用,或者您可以在自己的服务器上配置数据库,例如在AWS RDS数据库上。

假设您想要使用Heroku Postgres选项,您只需要将附加组件添加到您的应用程序中。通过这样做,Heroku将配置一个DATABASE_URL环境变量并为您保持更新。

在您的应用程序中,您需要做三件事:

  1. 在您的Gemfile中添加pg gem,并运行bundle update。您可能只想将此gem添加到Gemfile中的生产组。但我建议在开发和测试环境中也使用Postgres,以避免在某些情况下由于SQLite和Postgres的行为不同而遇到问题。

  2. 然后更新您的config/database.yml以使用Heroku设置的DATABASE_URL来配置数据库连接。这可能看起来像这样:

    production:
    adapter: postgresql
    url: <%= ENV['DATABASE_URL'] %>
    

    提交并推送这些更改到Heroku。

  3. 部署这些更改后,您需要在Heroku上运行迁移,通过运行heroku run rails db:migrate来从空白数据库开始,或者您可能希望从另一个数据库导入数据。

我建议阅读Heroku Dev Center中的Ruby数据库配置Heroku Postgres的相关信息。

英文:

It looks like your application is configured to use SQLite as database adapter and that there was no database found. Using SQLite will certainly not work because of Heroku's ephemeral file system (unless it is a read-only database).

Instead, the most common and best documented option is to use a Heroku PostgreSQL database that can be added as an add-on. Alternatively, there are other many other database add-ons available, or you could configure a database running on your own server or, for example, on an AWS RDS database.

Assuming you want to use the Heroku Postgres option, you simply need to add the add-on to your application. And by doing so, Heroku will configure a DATABASE_URL environment variable and keep it updated for you.

Within your application, you will need to do three things:

  1. Add the pg gem to your Gemfile and run bundle update. You might only want to add this gem to the production group in the Gemfile. But I suggest using Postgres in development and test environment too, to avoid running into issues because SQLite and Postgres behave differently in some cases.

  2. Then update your config/database.yml to use the DATABASE_URL set by Heroku to configure the database connection. That will likely have to look like this:

    production:
    adapter: postgresql
    url: <%= ENV['DATABASE_URL'] %>
    

    Commit and push those changes to Heroku.

  3. After deploying those changes, you will need to run migrations on Heroku by running heroku run rails db:migrate to start with an empty database, or you might want to import data from another database.

I suggest reading about Ruby Database Provisioning and Heroku Postgres in the Heroku Dev Center.

huangapple
  • 本文由 发表于 2023年2月16日 06:12:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75465910.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定