我正在使用Rails 3.2和ActiveAdmin 0.4.4开发一个应用程序.我的模型名为Teaser(/app/models/teaser.rb):
class Teaser < ActiveRecord::Base
attr_accessible :img, :name, :url
validates :img, :name, :presence => true
mount_uploader :img, TeaserUploader
end
Run Code Online (Sandbox Code Playgroud)
我添加了ActiveAdmin(/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
Run Code Online (Sandbox Code Playgroud)
现在,当我去'http:// localhost:3000/admin/teasers'时,我收到以下错误:
显示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行引发:收集不是分页范围.在调用之前设置collection.page(params [:page]).per(10):paginated_collection.
当我在linux上测试我的应用程序时,我得到了同样的错误(Ubuntu 12.04).
我可以通过这种方式解决这个问题(/app/admin/teaser.rb):
# encoding: UTF-8
ActiveAdmin.register Teaser, :as => 'Somename' do
Run Code Online (Sandbox Code Playgroud)
但是如果我使用这种方法,我就无法使用/app/config/locales/XX.yml来翻译这个模型
所有其他模型都正常工作.