问题描述
我的目标是在本地和我的登台服务器上使用Pry作为我的Rails应用程序的控制台。但我无法在Heroku上运行。
关于我在做什么的任何想法都是错误的
以下是我到目前为止所做的:
-
在我的 Gemfile 中,我添加了以下行:
gem'pry'
gem'pry-rails' -
我创建了一个名为 pry 的文件,其中包含:
#!/ usr / bin / env ruby
require'pry'
pry config / environments 中的所有文件都添加了以下内容:
silence_warnings做
开始
要求'撬'
IRB = Pry
rescue LoadError >
结束
结束 -
运行捆绑安装
- 运行 git push staging master
方法,但你提出了一个有趣的案例,我没有想过,因为我大部分与Sinatra和EM部署,并建立自己的助手等等。无论哪种方式:
要在拥有Rails应用程序时使用Pry和Heroku,只需将pry-rails和pry添加到您的gemfile(作为普通Gem),然后 bundle install 然后 git [commit | push] 并运行 heroku run console 在Cedar堆栈上。如果您调整了 config / environments 所做的调整的步骤3,则不应该这样做,因此请尽可能地恢复该更改。当你这样做,并从应用程序的根目录中删除pry脚本(你不一定需要做后者),Pry会正确加载你的Rails。
My goal is to use Pry as the console for my Rails app, both locally and on my staging server. But I can't get it to work on Heroku.
I'm following these instructions to get Heroku to use Pry as the console for my Rails app. When I run heroku run console pry, my console prints Running console pry attached to terminal... up, run.1 and then exits. When I run heroku console pry it just says main and then exits.
Any ideas on what I'm doing wrong?
Here's what I've done so far:
In my Gemfile I've added the lines:
gem 'pry'
gem 'pry-rails'I've created a file called pry which contains:
#!/usr/bin/env ruby
require 'pry'
pryI added the following to all the files in config/environments:
silence_warnings do
begin
require 'pry'
IRB = Pry
rescue LoadError
end
endrun bundle install
- run git push staging master
I am the one who developed the method for Heroku and Pry but you brought up an interesting case that I didn't think about since I mostly deploy with Sinatra and EM and build my own helpers and such. Either way:
To use Pry with Heroku while having a Rails app you just need to add pry-rails and pry to your gemfile (as a normal Gem) and then bundle install and then git [commit|push] and run heroku run console on Cedar stack. Step 3 of what you did where you adjusted config/environments does not and should not be done so please revert that change if you can. After you do that and remove the pry script from the root of your app (well you don't necessarily need to do the latter) Pry will load with your Rails properly.
这篇关于为什么Pry不会在Heroku的控制台中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!