我在heroku(cedar-stack)上运行rails控制台时遇到问题。以下每个命令heroku运行控制台,heroku运行rails控制台,heroku运行包exec rails console导致以下错误消息:
运行bundle exec rails console
附加到终端...向上,运行8155
中止测试:您的Rails环境正在生产模式下运行!
这个错误信息有点混乱。什么样的测试尝试heroku开始?我只是想启动4周前运行良好的控制台。
答案 0 :(得分:37)
对于Cedar Stack以及后来:
heroku run rails console --app <app name>
以前的堆栈可以使用此命令:
heroku run console --app <app name>
答案 1 :(得分:15)
如果您有多个环境(登台/生产/等),则需要以下命令:
heroku run -a app-name console
如果您只有一个环境而且从不设置暂存或其他环境,则可以运行:
heroku run console
https://github.com/nemrow/rails_app_cheatsheet/blob/master/heroku.rdoc
答案 2 :(得分:2)
出于某种原因,您需要在Procfile
:
# Procfile
web: script/rails server -p $PORT
console: script/rails console
此博客文章包含更多详细信息:http://platypus.belighted.com/blog/2013/01/21/ruby-2-rails-4-heroku/
答案 3 :(得分:2)
我遇到了同样的问题,我决定这样做并且有效
$ heroku run bash
$ cd bin
~/bin $ ruby rails console
答案 4 :(得分:1)
您应该使用heroku run console
,因为其他人已经回答了。
Heroku一次只能在一个环境中运行which is configured by the RAILS_ENV and RACK_ENV environments variables。
连接时,控制台将自动使用正确的环境。