我试图用Sinatra使用Figaro宝石。我安装了Figaro,它创建了以下文件/文件夹......
/config/application.yml
在这个文件中我添加了一些环境变量...
ENV['GMAIL_USERNAME']
ENV['GMAIL_PASSWORD']
然后在我的“app.rb”文件中,我试图包含yml文件,如...
require 'config/application.yml'
如何在app.rb文件中访问我的“ENV ['BIG_SECRET']”?
Mail.defaults do
delivery_method :smtp, {
:address => 'smtp.gmail.com',
:port => '587',
:domain => 'mydomain.com',
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
end
答案 0 :(得分:0)
您应该在application.yml中声明yuor变量,如Figaro github README https://github.com/laserlemon/figaro(YAML语法)中所述:
package...
import....
public class testing123 extends Fragment{
final Spinner a123 = (Spinner) getView().findViewById(R.id.spinner_a);
final Spinner b123 = (Spinner) getView().findViewById(R.id.spinner_b);
final String ax = a123.getSelectedItem().toString();
final String bx = b123.getSelectedItem().toString();
if (ax.equals("elephant")) {
//what is the best way to do it?
}else{}
}
您将能够按如下方式访问声明的变量:
pusher_app_id: "2954"
pusher_key: "7381a978f7dd7f9a1117"
pusher_secret: "abdc3b896a0ffb85d373"
test:
pusher_app_id: "5112"
pusher_key: "ad69caf9a44dcac1fb28"
pusher_secret: "83ca7aa160fedaf3b350"
...