Scrivener.Config.new/3 cannot be used in twice on params
LostKobrakai opened this issue · comments
I'm using scrivener_ecto and therefore have Scrivener.Config.new/3
be called in the Repo. Now I'd like to have some defaults set per controller as well and I'd like to simply use the functionality of Scrivener.Config
instead of rolling my own:
def index(conn, params) do
pagination_opts = Scrivener.Config.new(nil, [page_size: 2], params)
entries = query |> Repo.paginate(pagination_opts)
render conn, "index.html", entries: entries
end
This doesn't work, as Scrivener.Config
doesn't implement Enumerable
, which I feel like it could do without any major downsides.
You can pass your options directly to the paginate/1
function as a keyword. All standard keyword functions should work fine to programmatically build your options with defaults.