Tag: ruby

ruby savon和wsdl命名空间

我有一个问题,我认为是关于命名空间。 WSDL可以从这里下载: http : //promostandards.org/content/wsdl/Order%20Shipment%20NotificationService/1.0.0/OSN-1-0-0.zip 生成请求时,它看起来像这样: 1.0.0 myusername mypassword 3 2017-07-19 这导致肥皂故障。 当SoapUI使用相同的WSDL构造请求时,它看起来像这样 1.0.0 myusername mypassword 3 2017-07-19 您可以看到SoapUI已将用户名和密码放在“shar”命名空间内。 我注意到这并没有直接列在WSDL或WSDL直接加载的任何XSD文件中。 它被加载类似WSDL => XSD file =>包含shar命名空间的XSD文件。 这可能是问题吗? 如何将命名空间添加到3个键中? 我正在使用savon 2.11.1和nori 2.6.0 这是我最终使用的解决方案: @client = Savon.client( wsdl: ‘OSN-1-0-0/WSDL/1.0.0/OrderShipmentNotificationService.wsdl’, endpoint: @endpoint, env_namespace: :soapenv, namespaces: { “xmlns:shar” => “http://www.promostandards.org/WSDL/OrderShipmentNotificationService/1.0.0/SharedObjects/” }, element_form_default: :qualified, headers: { “accept-encoding” => “identity” } ) […]

如何从JSON字符串中访问值?

我有一个变量。 当我puts var_name我得到这个哈希: “{\”numConnections\”: 163}” 但是,当我尝试从值numConnections获取该数字163时,它无效。 这是我正在尝试的: connections = temp_var[“\”numConnections\””] puts connections.inspect 要么: connections = temp_var[“numConnections”] puts connections.inspect 两者同样不起作用。 知道如何从那里提取163吗?

如何在Ruby Regex中使用AND

我遇到Ruby正则表达式的问题。 你如何在ruby中做和(和)正则表达式? 例如: cat and dog cat dog I just want to match “cat and dog”

为什么循环中的Rake任务只执行一次?

我有连接到多个数据库的rails应用程序。 我编写了自定义rake任务,如下所示: task :migrate_accounts_schema => [:environment] do |t| users = User.find :all, :conditions => [“state = 2”], :order => “id asc” users.each do |user| if user.state == 2 ActiveRecord::Base.establish_connection( :adapter => “postgresql”, :host => user.database_host, :port => user.database_port, :username => user.subdomain, :password => “#{user.database_password}”, :database => user.database_name ) Rake::Task[“db:migrate”].invoke end end end 问题是任务执行db:仅针对用户[0]用户(集合中的第一个用户)进行迁移并且没有错误,只是静默地停止… 这是rake –trace的输出 […]

Rails现在正在使用Ruby 1.9吗?

可能重复: 是否可以使用Ruby 1.9x运行Ruby on Rails? 浏览网页说Rails与Ruby 1.9不兼容,但我想知道它是否总是如此? 我们还要等多久才能看到使用Ruby 1.9的Rails版本? 它正在进行中吗? 在开发阶段?

如何通过ActiveRecord行结果中的属性名称访问字段?

显然我在这里遗漏了一些明显的东西,但是会很欣赏一个简单的例子。 我从ActiveRecord回来了一条记录,我从查询中选择了几列。 这些字段是BigDecimal格式,需要展平为字符串。 我最初认为用以下方法提取查询就足够了: rows = ModelName.order(“date DESC”).select(‘table_name.precise_number1, table_name.precise_number2’).limit(100).all.zip rows_stringified1 = Array.new rows_stringified2 = Array.new readings.each do |row| rows_stringified1.push row[:precise_number1].to_s rows_stringified2.push row[:precise_number2].to_s end 但是,这会产生错误,例如can’t convert Symbol into Integer 。 显然,我没有完全遵循如何从行集结果中的记录访问列。 你通常会怎么做?

Appium服务器因没有新命令而关闭

我在Windows机器上使用Appium for Android本机应用程序自动化。 我的所有场景都表现良好,但有时App崩溃了,Appium停止说“没有在60秒内获得新命令,关闭”。 注意 – 如果明确地按下键盘上的任何键,它将获得黄瓜执行时执行的下一个命令。 我可以看到Appium正在发送查找元素的请求,但是没有收到任何响应。 我不知道为什么会这样,但同样的事情大多没有任何问题。 当这个问题发生时,Appium会关闭应用程序,接下来的场景也会失败。 有人帮助解决此问题。 这是Appium服务器日志: 信息:启动应用程序 info:[debug]试图杀死所有’uiautomator’进程 info:[debug]使用’uiautomator’获取所有进程 info:[debug]执行cmd:C:\ Users \ PG106 \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 300450adeedc3100 shell“ps’uiautomator’” info:[debug]找不到匹配的进程 info:[debug]运行bootstrap info:[debug]产生:C:\ Users \ PG106 \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -s 300450adeedc3100 shell […]

学习Ruby:推荐博客阅读?

我即将开始学习Ruby,并想要一些阅读材料来帮助我。 我在Ruby上寻找你的前5个博客,新闻和任何(活跃的)公告板(我可以处理新闻组,但我更喜欢在BB中阅读)。 谢谢,

在使用RVM的OS X上安装Ruby 1.9.3时,“没有可用的gcc46公式”:

我安装了Homebrew,我正在尝试安装RVM: rvm install 1.9.3-head 我收到此错误: 安装所需的包:gcc46 运行’requirements_osx_brew_libs_install gcc46’时出错, 请阅读/Users/mike/.rvm/log/1384918134_ruby-1.9.3-head/package_install_gcc46.log 要求安装失败,状态为:1 brew doctor说我准备酿造了。 在日志中我看到: 错误:下载失败: ftp : //gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2

在html文本中validationurl的存在

我想检测并过滤从表单发送的html文本,包含url或url。 例如,我从表格发送此html: RESOURCEShttp://stackoverflow.com/users/778094/hyperrjas https://github.com/hyperrjas http://www.linkedin.com/pub/juan-ardila-serrano/11/2a7/62  我不希望在html文本中允许或使用各种url / url 。 它可能是这样的: validate :no_urls def no_urls if text_contains_url errors.add(:url, “#{I18n.t(“mongoid.errors.models.profile.attributes.url.urls_are_not_allowed_in_this_text”, url: url)}”) end end 我想知道,如果html文本包含一个或多个url,我该怎么过滤?