Notifications Rails 5.2无法使用kaminari和通知进行分页

Notifications Rails 5.2无法使用kaminari和通知进行分页,notifications,ruby-on-rails-5,kaminari,Notifications,Ruby On Rails 5,Kaminari,我的一些文件: gem 'rails', '~> 5.2' gem 'notifications', '~> 0.6.0' gem 'kaminari' # notifications_controller.rb module Notifications class NotificationsController < Notifications::ApplicationController def index @notifications = not

我的一些文件:

gem 'rails', '~> 5.2'
gem 'notifications', '~> 0.6.0'
gem 'kaminari'
# notifications_controller.rb

module Notifications
  class NotificationsController < Notifications::ApplicationController
    def index
      @notifications = notifications.includes(:actor).order("id desc").page(params[:page])
      unread_ids = @notifications.reject(&:read?).select(&:id)
      Notification.read!(unread_ids)
      @notification_groups = @notifications.group_by { |note| note.created_at.to_date }
    end

    def clean
      notifications.delete_all
      redirect_to notifications_path
    end

    private

    def notifications
      raise "You need reqiure user login for /notifications page." unless current_user
      Notification.where(user_id: current_user.id)
    end
  end
end
mount Notifications::Engine, at: "notifications"
# notifications/notifications/index.html.erb

<div class="paginationBox">
   <%= paginate @notifications,left:2,right:1,window: 1 %>
</div>
NoMethodError - undefined method `total_pages' for #<Notification::ActiveRecord_Relation:0x00007fcfacae6dd8>:
  app/views/notifications/notifications/index.html.erb:33:in `_app_views_notifications_notifications_index_html_erb__2430601159943313679_70264929101860'
我的
通知\u controller.rb
如下:

gem 'rails', '~> 5.2'
gem 'notifications', '~> 0.6.0'
gem 'kaminari'
# notifications_controller.rb

module Notifications
  class NotificationsController < Notifications::ApplicationController
    def index
      @notifications = notifications.includes(:actor).order("id desc").page(params[:page])
      unread_ids = @notifications.reject(&:read?).select(&:id)
      Notification.read!(unread_ids)
      @notification_groups = @notifications.group_by { |note| note.created_at.to_date }
    end

    def clean
      notifications.delete_all
      redirect_to notifications_path
    end

    private

    def notifications
      raise "You need reqiure user login for /notifications page." unless current_user
      Notification.where(user_id: current_user.id)
    end
  end
end
mount Notifications::Engine, at: "notifications"
# notifications/notifications/index.html.erb

<div class="paginationBox">
   <%= paginate @notifications,left:2,right:1,window: 1 %>
</div>
NoMethodError - undefined method `total_pages' for #<Notification::ActiveRecord_Relation:0x00007fcfacae6dd8>:
  app/views/notifications/notifications/index.html.erb:33:in `_app_views_notifications_notifications_index_html_erb__2430601159943313679_70264929101860'
My
index.html
关于这样的通知:

gem 'rails', '~> 5.2'
gem 'notifications', '~> 0.6.0'
gem 'kaminari'
# notifications_controller.rb

module Notifications
  class NotificationsController < Notifications::ApplicationController
    def index
      @notifications = notifications.includes(:actor).order("id desc").page(params[:page])
      unread_ids = @notifications.reject(&:read?).select(&:id)
      Notification.read!(unread_ids)
      @notification_groups = @notifications.group_by { |note| note.created_at.to_date }
    end

    def clean
      notifications.delete_all
      redirect_to notifications_path
    end

    private

    def notifications
      raise "You need reqiure user login for /notifications page." unless current_user
      Notification.where(user_id: current_user.id)
    end
  end
end
mount Notifications::Engine, at: "notifications"
# notifications/notifications/index.html.erb

<div class="paginationBox">
   <%= paginate @notifications,left:2,right:1,window: 1 %>
</div>
NoMethodError - undefined method `total_pages' for #<Notification::ActiveRecord_Relation:0x00007fcfacae6dd8>:
  app/views/notifications/notifications/index.html.erb:33:in `_app_views_notifications_notifications_index_html_erb__2430601159943313679_70264929101860'
它不显示任何错误,但
kaminari
无法分页所有通知


那么,我哪里有错误呢?你能帮帮我吗?非常感谢

你在后端使用哪个数据库?你的数据库中是否有通知记录?我使用了
Mysql
,我可以在我的数据库中获得
notifications
记录。但是现在我无法在notifications
index.html.erb
中分页
total_pages
。谢谢@Abid lqbal…是因为数据库中没有通知记录吗?