【发布时间】:2016-06-12 22:55:09
【问题描述】:
我使用 gem 进行短信服务,我必须将参数放在特定的环境配置文件中。
静态参数一切正常,但如果我从数据库调用此参数,启动 webrick 时出现错误: (ActiveRecord::ConnectionNotEstablished)
这是我在 development.rb 中的原始代码
Skuby.setup do |config|
config.method = 'send_sms_classic' #default
config.username = 'myusername'
config.password = 'mypassword'
config.password = Setting.where(campo: 'skebby_password').valore
config.sender_string = 'company' #optional
config.sender_number = '39123456790' #optional
config.charset = 'UTF-8' #skebby default is ISO-8859-1
结束
改变一些东西,比如:
config.password = Setting.where(campo: 'skebby_password').valore
它下降了!
我该如何解决?
【问题讨论】:
-
你能提供你的
database.yml吗?您是否创建了数据库并运行了所有迁移? -
db 配置没问题,但似乎这个环境文件是在 db-connection 之前调用的
-
默认值:&default #adapter:mysql 适配器:mysql2 超时:5000 编码:utf8 测试:
-
您是否尝试将
skuby.setup行从环境文件中移出到类似config/initializers/skuby.rb的位置?
标签: ruby-on-rails environment-variables