继续尝试在 Rails 的一个应用程序中连接多个数据库的能力。这种能力是一个特定的生产要求,我是一个完整的新手......
所以我接受了之前的建议。请注意,我无法让应用程序从 database.yml 中读取“deals_qa”环境,或者至少它是这样出现的。
现在,最终结果是将我发送到应用程序生成的“糟糕”页面,我假设创建该页面是为了解决任何错误,因此没有具体说明为什么这不起作用。
请查看并提供任何建议,或我应该考虑的其他事项以使其正常工作...谢谢!
以下是基于先前建议的代码更改:
这是名为“dealsdb”的新模型文件:
module Dealsdb
@abstract_class = true
conn = { :adapter => 'mysql',
:encoding => 'utf8',
:reconnect => 'true',
:database => 'deals_qa',
:username => 'xxxxxx',
:password => 'xxxxxx',
:host => 'xx.xx.xx.xx',
:port => 'xxxx'
}
establish_connection(conn["deals_qa"])
end
end
class Members < Dealsdb::Base
def email_exists?(email)
unless email.blank? || SYSTEM_EMAILS.include?(email)
returning find_by_email(email) do |user|
end
end
end
end
这是现有 Account Controller 文件中对应的代码片段,文件名为 Account_Controller.rb。请注意,我只是想克服第一个条件。
if Dealsdb::Members.email_exists?(@email)
@Redirect_Flag = true
else
flash.now[:error] = 'Didnt MMS database check didnt work'
end
谢谢你!