Rails 3.2 ActiveAdmin“集合不是分页作用域”。错误 [英] Rails 3.2 ActiveAdmin 'Collection is not a paginated scope.' error

查看:76
本文介绍了Rails 3.2 ActiveAdmin“集合不是分页作用域”。错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rails 3.2和ActiveAdmin 0.4.4开发应用程序。
我有一个名为Teaser的模型(/app/models/teaser.rb):

I'm developing an application using Rails 3.2 and ActiveAdmin 0.4.4. I have model named Teaser (/app/models/teaser.rb):

class Teaser < ActiveRecord::Base
  attr_accessible :img, :name, :url
  validates :img, :name, :presence => true
  mount_uploader :img, TeaserUploader
end

我在其中添加了ActiveAdmin (/app/admin/teaser.rb):

And I added ActiveAdmin to it (/app/admin/teaser.rb):

# encoding: UTF-8
ActiveAdmin.register Teaser do
    form do |f|
        f.inputs "Teaser" do
            f.input :name, :label => 'Текст'
            f.input :url, :label => 'Ссылка'
            f.input :img, :as => :file, :label => 'Картинка'
        end
        f.buttons
    end
end

现在,当我转到 http:// localhost:3000 / admin / teasers时,出现以下错误:

Now, when I go to 'http://localhost:3000/admin/teasers', I get the following error:

显示C:/ RailsInstaller /Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb在第1行出现的地方:
集合不是分页范围。在调用:paginated_collection之前,设置collection.page(params [:page])。per(10)。

Showing C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb where line #1 raised: Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.

在Linux上测试我的应用程序时,我会遇到相同的错误(Ubuntu 12.04)。

I get the same error when I test my app on linux (Ubuntu 12.04).

我可以通过这种方式解决此问题(/app/admin/teaser.rb):

I can solve this problem by this way (/app/admin/teaser.rb):

# encoding: UTF-8
ActiveAdmin.register Teaser, :as => 'Somename' do

但是,如果使用此方法,则无法使用/ app /转换此模型config / locales / XX.yml

But if I use this method, I cannot translate this model by using /app/config/locales/XX.yml

所有其他模型都可以正常工作。

All other models work properly.

推荐答案

在某些情况下,您需要做的就是在活动管理员中更改模型的标签

In some cases all you need to do is change the model's label in active admin

示例

BREAKS

ActiveAdmin.register Stage do

工作

ActiveAdmin.register Stage, as: "Opportunity Stage" do

同一案例适用于模型页面

更新:5月30日

Update: 30-May

我又遇到了这个问题,


ActiveAdmin.register PageRedirects

ActiveAdmin.register PageRedirects do

并在 application_controller.rb 中,我有以下内容:

and in the application_controller.rb I had this:

before_filter :abc

def abc
  @page_redirects = ...
end

此方法会覆盖我猜想的主动管理控制器中的@page_redirects。

This method overrides the @page_redirects from the active-admin controller I guess.

这篇关于Rails 3.2 ActiveAdmin“集合不是分页作用域”。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆