当我使用capybara填写表单并在浏览器中打开页面时,字段为空.这是正常的吗?
page.fill_in 'Email', :with => 'test@gmail.com'
save_and_open_page
Run Code Online (Sandbox Code Playgroud) 我有这个任务:将字符串中的所有数字相加并执行乘法运算
input: "3 chairs, 2 tables, 2*3 forks" result: 11
我已经有正则表达式来执行此操作:
eval(str.match(/(\d[\d\.\*]*)/g).join(' + '))
Run Code Online (Sandbox Code Playgroud)
但我想添加选项来忽略括号内的数字"()"
input: "2 chairs, 3 tables (1 broke)" result: 5
怎么做?
正则表达式对我来说总是很痛苦:(
我需要选择与给定事务具有相同类型的事务.我需要检查它是否没有返回所有nil类型的事务.
使用ActiveRecord,我可以轻松编写:
given_transaction = Transaction.first
needed_transactions = Transaction.where('type != nil and type = ?', given_transaction.type)
Run Code Online (Sandbox Code Playgroud)
和所有的作品
当我尝试用mongoid写同样的东西时:
needed_transactions = Transaction.where(:type => given_transaction.type, :type.ne => nil)
Run Code Online (Sandbox Code Playgroud)
它生成以下查询:
"query"=>{:type=>{"$ne"=>"planned"}}
Run Code Online (Sandbox Code Playgroud)
换句话说,mongoid忽略第一次检查并仅使用对该字段的最后一次检查.
我尝试了"all_of","all_in","和" - 但仍然无法找到有效的解决方案.
也许我做错了什么......因为这个......我的世界正在颠倒...... :(((