@pagy is returning nil in my view (#<NoMethodError: undefined method 'pages' for nil:NilClass>).
It works as expected in the console:
> @pagy.pages
=> 25
> pagy_nav(@pagy)
=> "<nav class=\"pagy-nav pagination\"...
I've added the Pagy includes in the Folders Controller:
class FoldersController < ApplicationController
include Pagy::Backend
get '/folder/:permalink' do
@pagy, @pagination = pagy(Article.all)
end
helpers do
include Pagy::Frontend
end
end
I'm calling it in the Folder's Show View:
<%= pagy_nav(@pagy) if @pagy.pages > 1 %>
Any ideas why @pagy is returning nil inside the view?
Any advice on using Pagy in a Sinatra app?
@pagyneeds to be called before yourerbcall.Like this:
Not like this: