I installed ActiveAdmin successfully:
My gemfile code:
source \'https://rubygems.org\'
gem \'rails\', \'3.2.10\'
# Bundle edge Rails instead:
Active Admin need kaminari pagination If you want to use will paginate, you can make alias for will paginate functions to match kaminari one:
# 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
And this one worked for me.
I'm using Ruby 2.1.5p273 and Rails 4.1.8. I encountered the same problem.
@mohamed-ibrahim's answer solved the error underfined method 'per'
, but got another error
Showing c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/bundler/gems/activeadmin-06bf79c58216/app/views/active_admin/resource/index.html.arb where line #2 raised: wrong number of arguments (0 for 1)
Adding alias_method :total_count, :count
fixed it.
if defined?(WillPaginate)
module WillPaginate
module ActiveRecord
module RelationMethods
alias_method :per, :per_page
alias_method :num_pages, :total_pages
alias_method :total_count, :count
end
end
end
end
This worked for me:
initializers/will_paginate.rb
if defined?(WillPaginate)
module WillPaginate
module ActiveRecord
module RelationMethods
alias_method :per, :per_page
alias_method :num_pages, :total_pages
alias_method :total_count, :total_entries
end
end
end
end
I had the same issue and switched from WillPaginate to Kaminari for my app.
It is a simple change: paginate(page:1,per_page:10) becomes page(1).per(10)
I guess it depends how deeply willPaginate is enmeshed with your app.
The above answers do not work anymore. An updated answer was given here by @zitoon:
if defined?(WillPaginate)
module WillPaginate
module ActiveRecord
module RelationMethods
def per(value = nil) per_page(value) end
def total_count() count end
end
end
module CollectionMethods
alias_method :num_pages, :total_pages
end
end
end
I tried it myself. Works.
This one helped me:
if defined?(WillPaginate)
ActiveSupport.on_load :active_record do
module WillPaginate
module ActiveRecord
module RelationMethods
def per(value = nil) per_page(value) end
def total_count() count end
end
end
module CollectionMethods
alias_method :num_pages, :total_pages
end
end
end
end