从 ruby 连接到 cloudant NoSQL 数据库
Connecting to cloudant NoSQL database from ruby
我无法使用 couchrest_model 库连接到托管在 bluemix 上的 cloudant NoSQL 数据库。
我用 ruby 编写了类似的代码,它在我的计算机上运行良好(运行 在本地,没有 rails 或 sinatra):
require 'couchrest'
url = "https://blah-blah@url with credentials.com"
database_name = "testdb"
db = CouchRest.database!(url+"/"+database_name)
db.save_doc('_id':"dog",:name => 'MonthyPython', :date => Date.today)
doc = db.get('dog')
上面的代码成功地将数据写入我的数据库。然而,当我尝试用最新的 'couchrest_model' gem 做类似的事情时,我得到了
/Users/userpruser/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol (OpenSSL::SSL::SSLError)
我查看了好几页,但没有成功。那么让它与 ruby(没有 rails)or/and ruby+sinatra 一起工作的正确方法是什么?我找到了这个食谱 http://recipes.sinatrarb.com/p/models/couchdb 但我不知道如何 sed 环境变量以及如何将它们放在一起。
感谢您的帮助!
您是否尝试将端口显式设置为 443
并将协议显式设置为 'https'
?参见 https://github.com/couchrest/couchrest_model#configuration
看起来像是在安装
gem install sinatra-config-file
然后需要
require sinatra/config_file
解决了我的问题。谢谢大家!
我无法使用 couchrest_model 库连接到托管在 bluemix 上的 cloudant NoSQL 数据库。
我用 ruby 编写了类似的代码,它在我的计算机上运行良好(运行 在本地,没有 rails 或 sinatra):
require 'couchrest'
url = "https://blah-blah@url with credentials.com"
database_name = "testdb"
db = CouchRest.database!(url+"/"+database_name)
db.save_doc('_id':"dog",:name => 'MonthyPython', :date => Date.today)
doc = db.get('dog')
上面的代码成功地将数据写入我的数据库。然而,当我尝试用最新的 'couchrest_model' gem 做类似的事情时,我得到了
/Users/userpruser/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol (OpenSSL::SSL::SSLError)
我查看了好几页,但没有成功。那么让它与 ruby(没有 rails)or/and ruby+sinatra 一起工作的正确方法是什么?我找到了这个食谱 http://recipes.sinatrarb.com/p/models/couchdb 但我不知道如何 sed 环境变量以及如何将它们放在一起。
感谢您的帮助!
您是否尝试将端口显式设置为 443
并将协议显式设置为 'https'
?参见 https://github.com/couchrest/couchrest_model#configuration
看起来像是在安装
gem install sinatra-config-file
然后需要
require sinatra/config_file
解决了我的问题。谢谢大家!