小编Laz*_*dis的帖子

Rails&Couchbase - 内存泄漏

我有以下测试代码:

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控制台中执行该方法时,内存泄漏.

我正在使用:

  • couchbase 1.3.10 gem
  • libcouchbase 2.4.3

有任何想法吗?

更新:已 创建问题:https: //www.couchbase.com/issues/browse/RCBC-187

ruby caching ruby-on-rails couchbase

19
推荐指数
1
解决办法
502
查看次数

Rails:db/schema.rb中的差异 - null:false:created_at/updated_at列

有人知道为什么每当我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那里创建的而不是在开发数据库中?

mysql rake ruby-on-rails dbmigrate ruby-on-rails-3

10
推荐指数
1
解决办法
1816
查看次数

具有多个参数的RSpec和自定义匹配器

我正在尝试使用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)

但是使用上面定义的匹配器,我必须传递一个符号数组而不是用逗号分隔的符号,否则测试只会检查第一个符号.

有任何想法吗?

ruby rspec ruby-on-rails ruby-on-rails-3

6
推荐指数
1
解决办法
1982
查看次数

Rails - 延迟作业停止运行

我正在开发我已部署到OpenShift的这个应用程序.

我已经将实际的用户注册流程"移动"到了延迟的工作,因为在这期间有很多东西正在进行中.每隔两天(左右),延迟的作业流程就会停止运行.

在日志中我发现:

Error while reserving job: closed MySQL connection

我尝试使用以下命令启动它:

RAILS_ENV=production bin/delayed_job -m start

但问题仍然存在.

有任何想法吗?

ruby-on-rails delayed-job openshift ruby-on-rails-4

5
推荐指数
1
解决办法
1213
查看次数

类的源位置

我想找到在类中定义的实例方法(显式地使用def,而不是从其他调用派生的那些attr_accessor)

为此,我想到循环instance_methods(false)结果并检查每个方法source_location是否与类的源位置相同.

如何找到班级的源位置?

ruby

5
推荐指数
1
解决办法
726
查看次数