我有以下测试代码:
def loop_bucket_gets
bucket = Couchbase::Bucket.new({:node_list => ['xxx.xxx.xxx.xxx:8091', 'yyy.yyy.yyy.yyy:8091'],
:bucket => 'Foo',
:pool => 'default',
:expires_in => 1.day,
:default_format => :marshal,
:key_prefix => '_foo'
})
i = 0
loop do
begin
i += 1
bucket.get "ABC#{i}"
rescue ::Couchbase::Error::Base => e
nil
end
end
end
Run Code Online (Sandbox Code Playgroud)
当我在rails控制台中执行该方法时,内存泄漏.
我正在使用:
有任何想法吗?
更新:已 创建问题:https: //www.couchbase.com/issues/browse/RCBC-187
有人知道为什么每当我rake db:migrate在生产环境中运行时,schema.rb文件都会被更改?
差异仅在所有模型表的created_at,update_at列上:
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
Run Code Online (Sandbox Code Playgroud)
我知道这是它在生产数据库中找到的,但为什么它们是在null: false那里创建的而不是在开发数据库中?
我正在尝试使用RSpec为RoR中的测试创建自定义匹配器.
define :be_accessible do |attributes|
attributes = attributes.is_a?(Array) ? attributes : [attributes]
attributes.each do |attribute|
match do |response|
response.class.accessible_attributes.include?(attribute)
end
description { "#{attribute} should be accessible" }
failure_message_for_should { "#{attribute} should be accessible" }
failure_message_for_should_not { "#{attribute} should not be accessible" }
end
end
Run Code Online (Sandbox Code Playgroud)
我希望能够在我的测试中编写类似下面的内容:
...
should be_accessible(:name, :surname, :description)
...
Run Code Online (Sandbox Code Playgroud)
但是使用上面定义的匹配器,我必须传递一个符号数组而不是用逗号分隔的符号,否则测试只会检查第一个符号.
有任何想法吗?
我正在开发我已部署到OpenShift的这个应用程序.
我已经将实际的用户注册流程"移动"到了延迟的工作,因为在这期间有很多东西正在进行中.每隔两天(左右),延迟的作业流程就会停止运行.
在日志中我发现:
Error while reserving job: closed MySQL connection
我尝试使用以下命令启动它:
RAILS_ENV=production bin/delayed_job -m start
但问题仍然存在.
有任何想法吗?
我想找到在类中定义的实例方法(显式地使用def,而不是从其他调用派生的那些attr_accessor)
为此,我想到循环instance_methods(false)结果并检查每个方法source_location是否与类的源位置相同.
如何找到班级的源位置?