如何在没有限制的情况下查询ActiveResource?(How do I query ActiveResource without a limit?)

我试图使用其ruby REST API从Redmine实例收集对象的所有条目。 我正在尝试的代码:

require 'rubygems' require 'active_resource' class Issue < ActiveResource::Base self.site = '<site url>' self.user = '<username>' self.password = '<password>' self.format = :xml end test = Issue.all puts test.size test = Issue.all(:limit => 0) puts test.size

结果输出是:

25 25

数据库中有数千个条目,因此大小为25显然是关闭的。 我也试过“:limit => 10”并得到一个大小== 25,所以似乎完全忽略了':limit'参数。

我还尝试了Issue.find(:all,:limit => 0)和:limit => 10,两者都返回了size == 25.在没有限制的情况下查询active_resource的正确方法是什么?

I am attempting to collect all entries of an object from an instance of Redmine using its ruby REST API. The code I'm trying:

require 'rubygems' require 'active_resource' class Issue < ActiveResource::Base self.site = '<site url>' self.user = '<username>' self.password = '<password>' self.format = :xml end test = Issue.all puts test.size test = Issue.all(:limit => 0) puts test.size

The resulting output is:

25 25

There are thousands of entries in the database, so for the size to be 25 is clearly off. I also tried ":limit => 10" and got a size == 25, so it seems as though the ':limit' argument is being completely ignored.

I also tried Issue.find(:all, :limit => 0) and :limit => 10, both of which returned size == 25. What would be the correct method for querying active_resource without a limit?

最满意答案

似乎ActiveResource不支持“limit”选项。 如果您查看文档,您将看到可用选项是'from'和'params'。

我的猜测是返回的资源数量由服务服务器决定。 你尝试过这样的事吗?

Issue.all(params: { limit: 25})

如果我正确阅读了redmine api文档,这应该可行。

不幸的是,如文档中所述,100是限制参数的最大允许值。

limit:响应中存在的项目数(默认值为25,最大值为100)

您将必须发出多个请求并使用偏移量和限制参数来获取所有记录。

It seems that "limit" option is not supported by ActiveResource. If you check out the documentation you will see that available options are 'from', and 'params'.

My guess is that number of resources returned is decided by the service server. Did you try something like this?

Issue.all(params: { limit: 25})

This should work if I read the redmine api documentation correctly.

Unfortunately, as stated in documentation, 100 is maximum allowed value for limit param.

limit: the number of items to be present in the response (default is 25, maximum is 100)

You will have to make multiple requests and use offset and limit params to get all records.

如何在没有限制的情况下查询ActiveResource?(How do I query ActiveResource without a limit?)

我试图使用其ruby REST API从Redmine实例收集对象的所有条目。 我正在尝试的代码:

require 'rubygems' require 'active_resource' class Issue < ActiveResource::Base self.site = '<site url>' self.user = '<username>' self.password = '<password>' self.format = :xml end test = Issue.all puts test.size test = Issue.all(:limit => 0) puts test.size

结果输出是:

25 25

数据库中有数千个条目,因此大小为25显然是关闭的。 我也试过“:limit => 10”并得到一个大小== 25,所以似乎完全忽略了':limit'参数。

我还尝试了Issue.find(:all,:limit => 0)和:limit => 10,两者都返回了size == 25.在没有限制的情况下查询active_resource的正确方法是什么?

I am attempting to collect all entries of an object from an instance of Redmine using its ruby REST API. The code I'm trying:

require 'rubygems' require 'active_resource' class Issue < ActiveResource::Base self.site = '<site url>' self.user = '<username>' self.password = '<password>' self.format = :xml end test = Issue.all puts test.size test = Issue.all(:limit => 0) puts test.size

The resulting output is:

25 25

There are thousands of entries in the database, so for the size to be 25 is clearly off. I also tried ":limit => 10" and got a size == 25, so it seems as though the ':limit' argument is being completely ignored.

I also tried Issue.find(:all, :limit => 0) and :limit => 10, both of which returned size == 25. What would be the correct method for querying active_resource without a limit?

最满意答案

似乎ActiveResource不支持“limit”选项。 如果您查看文档,您将看到可用选项是'from'和'params'。

我的猜测是返回的资源数量由服务服务器决定。 你尝试过这样的事吗?

Issue.all(params: { limit: 25})

如果我正确阅读了redmine api文档,这应该可行。

不幸的是,如文档中所述,100是限制参数的最大允许值。

limit:响应中存在的项目数(默认值为25,最大值为100)

您将必须发出多个请求并使用偏移量和限制参数来获取所有记录。

It seems that "limit" option is not supported by ActiveResource. If you check out the documentation you will see that available options are 'from', and 'params'.

My guess is that number of resources returned is decided by the service server. Did you try something like this?

Issue.all(params: { limit: 25})

This should work if I read the redmine api documentation correctly.

Unfortunately, as stated in documentation, 100 is maximum allowed value for limit param.

limit: the number of items to be present in the response (default is 25, maximum is 100)

You will have to make multiple requests and use offset and limit params to get all records.