[英]increase the limit of record in csv download
I have more than 50K records in database but when I download a csv from active admin it gives me just 10K.我在数据库中有超过 5 万条记录,但是当我从活动管理员下载 csv 时,它只给了我 1 万条记录。 I have googled the solutions and got that there is limit in the method named max_csv_records in我用谷歌搜索了解决方案,发现名为 max_csv_records 的方法有限制
lib/active_admin/resource_controller/collection.rb lib/active_admin/resource_controller/collection.rb
is there some way from which I can override this and increase the limit ?有什么方法可以覆盖它并增加限制吗?
Here's the gist I got https://gist.github.com/3177995 but can you guys tell me how can I use this code ?这是我得到的要点https://gist.github.com/3177995但你们能告诉我如何使用这段代码吗? It would be much better if I can add something in active admin initializer如果我可以在活动管理员初始值设定项中添加一些内容会更好
Just for future googlers.只为未来的谷歌员工。 My fix (working for the current Master 1.0.0pre) is to add the following to config/initializers/active_admin.rb
:我的修复(适用于当前的 Master 1.0.0pre)是将以下内容添加到config/initializers/active_admin.rb
:
module ActiveAdmin
class ResourceController
module DataAccess
# needed for current active admin master
def max_per_page
30_000
end
def per_page
return 30_000 if %w(text/csv application/xml application/json).include?(request.format)
return max_per_page if active_admin_config.paginate == false
@per_page || active_admin_config.per_page
end
end
end
end
Replace the max as needed.根据需要更换最大值。 This works for csv, xml and json downloads.这适用于 csv、xml 和 json 下载。
这是用于增加导出记录限制的猴子补丁https://github.com/gregbell/active_admin/issues/346
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.