Rails 散列为 will_paginate 格式
Rails hash to will_paginate format
我有一个散列,其中包含一个散列数组(票证)和通过 API 调用接收的元数据。端点使用 will_paginate gem 和 returns 结果。
有没有办法将此散列转换为可用作视图中 will_paginate
的参数的格式?
will_paginate
可以使用普通数组代替 ActiveRecord 作用域。
你只需要在之前处理你的数据。有很多关于如何做到这一点的资源:
https://makandracards.com/makandra/13521-will_paginate-can-paginate-plain-ruby-arrays
https://gist.github.com/denmarkin/817327
我有一个散列,其中包含一个散列数组(票证)和通过 API 调用接收的元数据。端点使用 will_paginate gem 和 returns 结果。
有没有办法将此散列转换为可用作视图中 will_paginate
的参数的格式?
will_paginate
可以使用普通数组代替 ActiveRecord 作用域。
你只需要在之前处理你的数据。有很多关于如何做到这一点的资源:
https://makandracards.com/makandra/13521-will_paginate-can-paginate-plain-ruby-arrays
https://gist.github.com/denmarkin/817327