TinyTds ::错误:Adaptive Server连接失败

这是一个奇怪的。 我的机器上有一些ruby代码,它使用tiny_tds版本:0.6.0.rc1 一切正常。 当同事尝试运行相同的代码时,他会收到以下错误: TinyTds ::错误:Adaptive Server连接失败 我们正在连接而不提供用户名或密码,因为我的机器上不需要它。 有任何想法吗? 这可能是sql数据库上的权限吗? 提前致谢 在机器上应该注意我们安装了SQL 2008 R2和SQL Express的问题。 我们可以连接到SQL Express而不是SQL 2008 R2 这是我们正在使用的代码 def self.GetTestMprsFromDB(dataServer,database,query) mprids = Array.new client = TinyTds::Client.new(:dataserver => dataServer, :database => database, :timeout => 1000) 在初始化时踩到tiny_tds def initialize(opts={}) if opts[:password] && opts[:password].to_s.strip != ” opts[:password] = opts[:password].to_s warn ‘FreeTDS may have issues with passwords […]

找不到文件’twitter / bootstrap’(ROR)

这是链接https://github.com/Gtar69/games 我遇到了问题 我已完成采购如下 在Gemfile中: gem “bootstrap-sass” 在终端 bundle install 在app/assets/stylesheets/application.css *= require bootstrap 但是本地服务器仍然无法显示bootstrap形成,因为它说找不到bootstrap … 谢谢你的帮助〜

麻烦用Ruby的’open-uri’打开utf-8 URI

我正在尝试使用ruby和open-uri从谷歌地图Web服务API获取丹麦的位置地址。 试图让Ærø,丹麦 : http : //maps.googleapis.com/maps/api/geocode/json?address=ærø&sensor=false&region=dk在Chrome中运行时不支持open-uri: require ‘rubygems’ require “open-uri” require ‘json’ uri = “http://maps.googleapis.com/maps/api/geocode/json?address=ærø&sensor=false&region=dk” response = open(uri) array = JSON.parse(response) pp array 在这里它产生 /usr/lib/ruby/1.8/uri/common.rb:436:in `split’: bad URI(is not URI?): http://maps.googleapis.com/maps/api/geocode/json?address=ærø&sensor=false&region=dk (URI::InvalidURIError) 另一种方法是逃避角色: uri = “http://maps.googleapis.com/maps/api/geocode/json?address=ærø&sensor=false&region=dk” uri_escaped = URI.escape(uri) response = open(uri_escaped) array = JSON.parse(response.read) pp array 但这会产生一个逃脱的结果(这不是追求:-) 任何人都知道什么可以解决这个问题(获得未转发的反馈或发送utf-8请求)? 这里的Ruby版本是1.8.7

错误:执行gem时…(OpenSSL :: X509 :: StoreError)

我试图以管理员身份将serialport安装到Windows 7中,但我遇到以下错误: C:\Sites>gem install serialport ERROR: While executing gem … (OpenSSL::X509::StoreError) 我尝试了以下内容,但他们没有帮助: OpenSSL :: X509 :: StoreError:cert已经在哈希表中? Ruby在哪里寻找SSL_CERT_FILE? 我试图从网上找到这些解决方案。 但是,它仍然无法工作。 有任何想法吗? 以下是我的电脑的gem环境: C:\Sites>gem env RubyGems Environment: – RUBYGEMS VERSION: 2.2.2 – RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [i386-mingw32] – INSTALLATION DIRECTORY: C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0 – RUBY EXECUTABLE: C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe – EXECUTABLE DIRECTORY: C:/RailsInstaller/Ruby2.1.0/bin – SPEC CACHE DIRECTORY: C:/Users/5004118294/.gem/specs […]

Ruby – 使用标头发送GET请求

我想用一个网站的api来使用ruby。 说明是发送带有标头的GET请求。 这些是来自网站的说明和他们提供的示例php代码。 我要计算一个HMAC哈希并将其包含在apisign头下。 $apikey=’xxx’; $apisecret=’xxx’; $nonce=time(); $uri=’https://bittrex.com/api/v1.1/market/getopenorders?apikey=’.$apikey.’&nonce=’.$nonce; $sign=hash_hmac(‘sha512’,$uri,$apisecret); $ch = curl_init($uri); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘apisign:’.$sign)); $execResult = curl_exec($ch); $obj = json_decode($execResult); 我只是在命令提示符下使用安装在windows上的ruby的.rb文件。 我在ruby文件中使用net / http。 如何发送带标题的GET请求并打印响应?

枚举#with_object与enum#each_with_object的不同之处是什么?

文件说: enum#each_with_object :- 使用任意对象obj迭代每个元素的给定块,并返回obj enum#with_object:- 使用任意对象obj迭代每个元素的给定块,并返回obj 但是当我在这两个结构上尝试下面的内容时,一个人给了我预期的输出,但其他人没有。 所以我怀疑这两种结构之间存在差异。 使用each_with_object %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } => {“foo”=>”FOO”, “bar”=>”BAR”} 在这里成功! 使用with_object %w(foo bar).with_object({}) { |str, hsh| hsh[str] = str.upcase } => NoMethodError: undefined method `with_object’ for [“foo”, “bar”]:Array from (irb):1 from C:/Ruby193/bin/irb:12:in `’ 失败了! 那么这两种方法有什么区别呢?

使用最大行长度简洁地序列化JSON

所以我正在生成一个可能冗长的JSON字符串,用于Sendgrid的SMTP API。 因为它作为SMTP标头,它应该有一个最大行长度(建议72,但绝对不超过1000)。 一个天真的解决方案在最后的文档中描述: http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/ 他们建议这样做: $js =~ s/(.{1,72})(\s)/$1\n /g; 但我不喜欢这样,因为它可以在空格有意义的字符串内分割。 此外,当空间很少而且很远时,表现似乎可能非常糟糕。 现在我正在使用Ruby,我可以做类似的事情: JSON.generate(@hash, options) 其中选项提供了http://flori.github.com/json/doc/classes/JSON.html#method-i-generate中记录的不同格式选项。 但是这些都没有给我我想要的东西,这是每隔一段时间用简化线条简洁的JSON。 有任何想法吗?

正则表达式捕获具有多行值的冒号分隔的键值对

我目前正在使用Ruby on Rails(在Eclipse中)开发一个项目,我的任务是使用正则表达式将一个数据块拆分成相关的部分。 我决定根据3个参数分解数据: 该行必须以大写字母开头(RegEx等价 – /^[AZ]/ ) 它必须以:( RegEx等价物 – /$”:”/ )结束 我会感激任何帮助….我在我的控制器中使用的代码是: @f = File.open(“report.rtf”) @fread = @f.read @chunk = @fread.split(/\n/) 其中@chunk是将由拆分创建的数组, @fread是正在拆分的数据(按新行)。 任何帮助将不胜感激,非常感谢! 我无法发布确切的数据,但它基本上是由此(这在医学上相关) 考试1:CBW 8080 结果: 该报告由具体测量决定。 请参阅原始报告。 比较:2012年1月30日,3/8/12,4/9/12 RECIST 1.1:BLAH BLAH BLAH 理想的输出是一个数组,表示: [“Exam 1:”, “CBW 8080”, “RESULT”, “This report is dictated with specific measurement. Please see the original report.”, […]

在Mac OS 10.5.8上通过RVM安装Ruby 1.8.7-p302时运行make时出错

运行“rvm install 1.8.7-p302”提供以下反馈: rich-macbook:~ rich$ rvm install 1.8.7-p302 Installing Ruby from source to: /Users/rich/.rvm/rubies/ruby-1.8.7-p302, this may take a while depending on your cpu(s)… ruby-1.8.7-p302 – #fetching ruby-1.8.7-p302 – #extracted to /Users/rich/.rvm/src/ruby-1.8.7-p302 (already extracted) Applying patch ‘stdout-rouge-fix’ (located at /Users/rich/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch) ERROR: Error running ‘patch -F 25 -p1 -N -f <"/Users/rich/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch"', please read /Users/rich/.rvm/log/ruby-1.8.7-p302/patch.apply.stdout-rouge-fix.log ruby-1.8.7-p302 – #configuring […]

将Python脚本转换为Ruby时出错

我使用的是使用xmlrpclib的Python脚本: import xmlrpclib srv = xmlrpclib.ServerProxy(“http://demo.myslice.info:7080/”, allow_none=True) # authentication token auth = {“AuthMethod”: “password”, “Username”: “guest”, “AuthString”: “guest”} ret = srv.Get(auth, “slice”, [[“slice_hrn”, ‘=’, “ple.upmc.myslicedemo”]], {}, [“slice_hrn”]) print ret 我想使用Ruby进行类似的XML-RPC调用。 为此,我使用了以下代码: require “xmlrpc/client” require “pp” XMLRPC::Config.module_eval do remove_const :ENABLE_NIL_PARSER const_set :ENABLE_NIL_PARSER, true end ret = XMLRPC::Client.new2(“http://demo.myslice.info:7080/”) auth = {“AuthMethod” => “password”, “Username” => “guest”, “AuthString” […]