I am trying to connect to my pusher server but am receiving the error:
我正在尝试连接到我的推送服务器但收到错误:
Missing client configuration: please check that key, secret and app_id are configured.
缺少客户端配置:请检查是否已配置密钥,密码和app_id。
I want to check my environmental variables, but cannot find any clear way to do this on Stack Overflow yet.
我想检查我的环境变量,但在Stack Overflow上找不到任何明确的方法。
5 个解决方案
#1
18
Printing the Environment from the Shell
As other answers have pointed out, one can use /usr/bin/env
or /usr/bin/printenv
from the command line to see what the environment is in the shell before starting Rails, or in a subshell after starting it. For example:
正如其他答案所指出的那样,可以从命令行使用/ usr / bin / env或/ usr / bin / printenv来查看在启动Rails之前shell中的环境,或者在启动它之后的子shell中。例如:
-
rails s
RETURN - rails s RETURN
- CTRL-Z
- CTRL-Z
-
env
RETURN - 环回归
-
fg
RETURN - fg返回
Displaying ENV from the View Layer
In Ruby, ENV is a "hash-like" accessor for environment variables; it is not actually a Hash. You can introspect ENV from your Rails console easily enough simply by typing ENV
or ENV['foo']
, but sometimes you may want to see what Rails thinks the environment is during rendering. In that case, you want the Rails debug helper. For example:
在Ruby中,ENV是环境变量的“类哈希”访问器;它实际上不是哈希。只需键入ENV或ENV ['foo']就可以轻松地从Rails控制台中反省ENV,但有时您可能希望看到Rails在渲染过程中认为环境是什么。在这种情况下,您需要Rails调试助手。例如:
# ERB
<%= debug ENV.to_h.to_yaml %>
# HAML
= debug ENV.to_h.to_yaml
Calling #to_yaml to serialize the ENV object will make the output easier to read, but requires you to convert ENV to a hash or array first. You can also just invoke debug ENV
without chaining; it's just harder on the eyes.
调用#to_yaml来序列化ENV对象将使输出更容易读取,但需要先将ENV转换为散列或数组。你也可以不用链接调用调试ENV;它只是在眼睛上更难。
#2
6
Use command ENV
in rails console. That will return a hash of your environmental values you can access. Alternatively, you can access your environmental variables from your apps root path using the same command and the variables will be returned formatted.
在rails控制台中使用命令ENV。这将返回您可以访问的环境值的哈希值。或者,您可以使用相同的命令从应用程序根路径访问环境变量,并且将返回格式化的变量。
#3
6
Or use the O/S shell, in Ubuntu use
或者在Ubuntu中使用O / S shell
printenv
#4
1
Both of these commands will print to stdout your environment variables:
env
ENV
printenv
printenv
#5
0
I have also used the following in the view layer:
我还在视图层中使用了以下内容:
<% request.env.each do |key, value| %>
<strong><%= key %></strong> => <%= value %><br/>
<% end %>
I found it very helpful to debug issues caused by env variables set at the passenger/nginx level, that would not show up when I used rails console.
我发现调试由乘客/ nginx级别设置的env变量引起的问题非常有帮助,当我使用rails console时不会显示这些问题。
#1
18
Printing the Environment from the Shell
As other answers have pointed out, one can use /usr/bin/env
or /usr/bin/printenv
from the command line to see what the environment is in the shell before starting Rails, or in a subshell after starting it. For example:
正如其他答案所指出的那样,可以从命令行使用/ usr / bin / env或/ usr / bin / printenv来查看在启动Rails之前shell中的环境,或者在启动它之后的子shell中。例如:
-
rails s
RETURN - rails s RETURN
- CTRL-Z
- CTRL-Z
-
env
RETURN - 环回归
-
fg
RETURN - fg返回
Displaying ENV from the View Layer
In Ruby, ENV is a "hash-like" accessor for environment variables; it is not actually a Hash. You can introspect ENV from your Rails console easily enough simply by typing ENV
or ENV['foo']
, but sometimes you may want to see what Rails thinks the environment is during rendering. In that case, you want the Rails debug helper. For example:
在Ruby中,ENV是环境变量的“类哈希”访问器;它实际上不是哈希。只需键入ENV或ENV ['foo']就可以轻松地从Rails控制台中反省ENV,但有时您可能希望看到Rails在渲染过程中认为环境是什么。在这种情况下,您需要Rails调试助手。例如:
# ERB
<%= debug ENV.to_h.to_yaml %>
# HAML
= debug ENV.to_h.to_yaml
Calling #to_yaml to serialize the ENV object will make the output easier to read, but requires you to convert ENV to a hash or array first. You can also just invoke debug ENV
without chaining; it's just harder on the eyes.
调用#to_yaml来序列化ENV对象将使输出更容易读取,但需要先将ENV转换为散列或数组。你也可以不用链接调用调试ENV;它只是在眼睛上更难。
#2
6
Use command ENV
in rails console. That will return a hash of your environmental values you can access. Alternatively, you can access your environmental variables from your apps root path using the same command and the variables will be returned formatted.
在rails控制台中使用命令ENV。这将返回您可以访问的环境值的哈希值。或者,您可以使用相同的命令从应用程序根路径访问环境变量,并且将返回格式化的变量。
#3
6
Or use the O/S shell, in Ubuntu use
或者在Ubuntu中使用O / S shell
printenv
#4
1
Both of these commands will print to stdout your environment variables:
env
ENV
printenv
printenv
#5
0
I have also used the following in the view layer:
我还在视图层中使用了以下内容:
<% request.env.each do |key, value| %>
<strong><%= key %></strong> => <%= value %><br/>
<% end %>
I found it very helpful to debug issues caused by env variables set at the passenger/nginx level, that would not show up when I used rails console.
我发现调试由乘客/ nginx级别设置的env变量引起的问题非常有帮助,当我使用rails console时不会显示这些问题。