I borrowed this code from this web page.
def pagination_text(list) do
~e"""
Page: <%= comma_number(list.page) %> of <%= comma_number(calculate_pages(list.count, list.per_page)) %> - Records <%= list.first %> to <%= list.last %> of <%= comma_number(list.count) %>
"""
end
def pagination_links(conn, list, route) do
content_tag :div, class: "pagination" do
children = []
if list.has_prev do
children = children ++ link "Previous", to: route.(conn, :index, page: list.prev_page), class: "btn btn-secondary"
end
if list.has_next do
children = children ++ link "Next", to: route.(conn, :index, page: list.next_page), class: "btn btn-secondary"
end
children
end
end
When I invoke the pagination_text function, it works
<%= Ptrack.PaginationHelpers.pagination_text(@tickets) %>
When I invoke the pagination_links function, it generates an empty div
<%= Ptrack.PaginationHelpers.pagination_links(@conn, @tickets, &ticket_path/3) %>
If I ‘hard-code’ the guts of the pagination_links function in my view, it works
<div class="padded-top padded-bottom">
<%= if @tickets.has_prev do %>
<span><%= link "⫷ Previous", to: ticket_path(@conn, :index, page: @tickets.prev_page), class: "btn btn-primary" %></span>
<% end %>
<%= if @tickets.has_next do %>
<span><%= link "Next ⫸", to: ticket_path(@conn, :index, page: @tickets.next_page), class: "btn btn-primary" %></span>
<% end %>
</div>
Can anyone spot what I am doing wrong?