У меня есть несколько новых действий для модели уведомления, и все начинает становиться беспорядочным, поэтому я реорганизовал с <% = render @other_notifications %>
с notifcations/_notification.html.erb
в следующую структуру.рельсы will_paginate с различными частями
Моя проблема заключается в следующем. Страница отображает все хорошо, но разбиение на страницы не работает должным образом. Поэтому, если у меня есть структура ниже и не удаляет _notification.html.erb
, тогда страница будет загружена с помощью новых действий, а объекты разбиения на страницы будут загружены _notification.html.erb
. ЕСЛИ я удаляю _notification.html.erb
, тогда страница по-прежнему загружается с новыми частицами, но разбиение на страницы не работает. Как мне изменить разбивку на страницы, чтобы сделать эту работу?
notifications_controller.rb
def other_notifications
@other_notifications = current_user.notifications.not_chat.order(created_at: :desc).includes(:sender_profile).
paginate(page: params[:page], per_page: Notification.pagination_per_page)
current_user.reset_new_other_notifications
respond_to do |format|
format.html
format.js
end
end
other_notifications.html.erb
<div class = "other-notifications-index">
<% @other_notifications.each do |notification| %>
<% if lookup_context.template_exists?(notification.action, "notifications/actions", true) %>
<%= render partial: "notifications/actions/#{notification.action}", locals: { notification: notification } %>
<% end %>
<% end %>
</div>
<div id="infinite-othernotification-scrolling">
<%= will_paginate @other_notifications %>
</div>
other_notifications.js.erb
$('.other-notifications-index').append('<%= j render @other_notifications %>');
<% if @other_notifications.next_page %>
$('.pagination').replaceWith('<%= j will_paginate @other_notifications %>');
<% else %>
$(window).off('scroll');
$('.pagination').remove();
$('.no-more').delay(1000).fadeIn(1500);
<% end %>