gpt4 book ai didi

activeadmin - Rails:activeadmin,未定义方法 `per' 用于 #

转载 作者:行者123 更新时间:2023-12-03 23:59:11 26 4
gpt4 key购买 nike

我成功安装了 ActiveAdmin:

我的 gemfile 代码:

源' https://rubygems.org '

 gem 'rails', '3.2.10'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

gem 'twitter-bootstrap-rails'

gem 'activeadmin'

# gem "meta_search", '>= 1.1.0.pre'
gem "spud_photos"
gem 'devise'

gem 'cancan'
gem 'rolify'

我这样做了:
 bundle
rails g active_admin:install
rake db:migrate
rails g active_admin:resource product

我将一些模型链接到 ActiveAdmin。

单击产品链接上的仪表板后出错:
 undefined method `per' for #<ActiveRecord::Relation:0x4d15ee0>

最佳答案

事件管理员需要 kaminari分页
如果你想使用 will paginate,你可以为 will paginate 函数创建别名以匹配 kaminari 一:

# config/initializers/will_paginate.rb
if defined?(WillPaginate)
module WillPaginate
module ActiveRecord
module RelationMethods
alias_method :per, :per_page
alias_method :num_pages, :total_pages
end
end
end
end

module ActiveRecord
class Relation
alias_method :total_count, :count
end
end

这个对我有用。

关于activeadmin - Rails:activeadmin,未定义方法 `per' 用于 #<ActiveRecord::Relation:0x4d15ee0>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14958438/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com