Ruby on Rails с использованием active_admin и ransack, ошибка подкачки на ресурсе active_admin:resource

Ошибка: Коллекция не является областью действия с разбивкой на страницы. Установите collection.page(params[:page]).per(10) перед вызовом :paginated_collection.

unless collection.respond_to?(:num_pages)
          raise(StandardError, "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.")
        end
        @contents = div(class: "paginated_collection_contents")

приложение_контроллер:

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  helper_method :all_categories
  helper_method :all_posts
  before_filter :site_search
  def all_categories
    @categories = Category.all
  end
  def all_posts
    @all_posts = Post.all
  end
  def site_search
      @q = Post.ransack(params[:q])
      #@posts_search = @q.result(distinct: true)
      @search_posts = @q.result(distinct: true)
  end
end

Ресурс ActiveAdmin: сообщение

 ActiveAdmin.register Post do
  permit_params   :title, :body, :category_id, :admin_user_id
  menu :label => "Blog Posts"
  index do
  column :title
    column "Author",:admin_user
    column :category
    column :created_at
    default_actions
  end
  end

индексный метод контроллера сообщений:

 def index
      #@content_first = Post.find(1).title
      #@content_second = "This is 2";
      @q = Post.ransack(params[:q])
      @posts = @q.result(distinct: true)
      #@posts = Post.all
    end
 end

person Jackal Cooper    schedule 26.12.2015    source источник
comment
Я нашел некоторые ответы, связанные. Это говорит о конфликте имен переменных. У меня есть эта проблема здесь?   -  person Jackal Cooper    schedule 26.12.2015


Ответы (1)


Догадаться. Я не переделывал модели полностью. Для тех у кого похожие проблемы: 1. Попробуйте переименовать свои переменные 2. Проверьте свои модели

person Jackal Cooper    schedule 26.12.2015