drewolson / scrivener

Pagination for the Elixir ecosystem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

no function clause matching in Scrivener.HTML.pagination_links/2

andrewcottage opened this issue · comments

When trying to use the library I get

no function clause matching in Scrivener.HTML.pagination_links/2

my html looks like this

<div class="col-sm-12">
    <h3 class="text-center">Recent Auctions</h3>
    <%= for auction <- @recent_auctions do %>
      <%= render "auction_block.html", auction: auction %>
    <% end %>
    <%= pagination_links @conn, @page %>
  </div>

my controller looks like

query = from a in Auction,
             order_by: [desc: a.time],
             preload: [:state, :city, :facility]
      page = Repo.paginate(query, params)

      assign(conn, :user_city, nil)
      |> assign(:auctions, page.entries)
      |> assign(:page_number, page.page_number)
      |> assign(:page_size, page.page_size)
      |> assign(:total_pages, page.total_pages)
      |> assign(:total_entries, page.total_entries)
      |> assign(:recent_auctions, page.entries)
      |> assign(:page, page.entries)
      |> assign(:recent_auctions_for_user_city, [])

Any ideas what is going on?

This seems like a potential issue with scrivener_html, not this library.

Sorry about that. I thought I was on the scrivener_html page.

Hello @andrewcottage,

Not sure if you open issue at scrivener_html

As I can see in your controller, the page assigns its not correct.

assign(:page, page.entries)

Documentation says the following:

Where @page is a %Scrivener.Page{} struct returned from Repo.paginate/2

So you need to assign the complete struct

|> assign(:page, page)

Hope, it helps.