[英]How can I run rails console in Heroku? Rails 5.1 and postgresql
我一直在关注Rails应用程序的教程。 本教程基于Rails 5,我正在使用Rails 5.1.2。 一切都在本地运行良好,并毫无问题地推送至heroku。 但是,当我通过运行在生产数据库上创建管理员用户时:
$ heroku run rails c
它返回以下错误:
/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in
require': cannot load such file -- rack/handler/c (LoadError) from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in
在/app/vendor/bundle/ruby/2.4.0/来自/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb的gems / activesupport-5.1.3 / lib / active_support / dependencies.rb:258:在load_dependency' from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:292:in
require'来自/app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/handler.rb:74:intry_require' from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/rack/handler.rb:16:in
get'from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.3/lib/server' from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:68:in
:在server' from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:68:in
rack / server.rb:301:在server' from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:68:in
从/app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:38:instart' from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:131:in
在执行中从/ app / vendor / bundle中阻止/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:126:intap' from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:126:in
从/app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb执行:27:在run' from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in
invoke_command'来自/ app / vendor / bundle / ruby /2.4.0/gems/thor-0.20.0/lib/thor.rb:387dispatch' from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/command/base.rb:63:in
执行中/app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/command.rb:44:in在invoke' from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.3/lib/rails/commands.rb:16:in
'从仓/轨道:9:在require' from bin/rails:9:in
“`
为了解决这个问题,我可以运行:
$ heroku run bash
$ rails c
这使我可以更新生产数据库。 虽然这可行,并且可以满足我的需求。 我想知道为什么原始命令不起作用。 我到处都在寻找答案,无法找到适用于我的任何内容。 我正在尝试提高自己的开发技能,并且想了解为什么原始问题无法解决。
我可以添加任何人需要查看的文件,但是我什至不知道哪个文件与该问题有关。
您可以指定应用名称,以防万一:
heroku run rails c -a APP_NAME
我的理解是heroku run
命令是由Heroku命令行界面(CLI)提供的。 CLI不知道如何处理 。 但是,运行rails c
命令heroku run bash
将启动一个新的dyno,并提供对Unix shell的访问,您可以在其中运行命令(即rails c),就像本地终端一样。 有关更多信息,请参见: https : //devcenter.heroku.com/articles/how-heroku-works 。
编辑修复错误:CLI确实知道如何处理rails c
命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.