I have two models (events & artists) pagy is working fine with my artist model, but my event model isn't displaying last records #450
-
I do have a more elaborate index method in my events controller
In my events index page I have:
When I remove my upcoming_events scope, the records will display correctly. In my event.rb model I have:
Am I missing something in order to get pagy with work with my event scope? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
My best guess is that you ought to apply all scopes BEFORE passing into pagy:. I"m not sure about the ransack operations required to make it work, but as far as pagy is concerned, I can suggest the following: - @pagy, @events = pagy(@q.result(distinct: true))
+ @pagy, @events = pagy( get_upcoming_events_here) - <% @events.upcoming_events.each do |event| %> #no don't apply after paginating, do it before
+ <% @events.each do |event| %> |
Beta Was this translation helpful? Give feedback.
-
Not very clear what you describe, but if you mean that you have 2 sections in the view, you should use 2 different sets of events and pagy objects that work independently from each other. |
Beta Was this translation helpful? Give feedback.
-
Documentation: Paginate multiple independent actions and Using different page_param |
Beta Was this translation helpful? Give feedback.
Documentation: Paginate multiple independent actions and Using different page_param