Search code examples
ruby-on-railsactiveadminfriendly-id

Rails: ActiveAdmin doesn't work with Friendly_id


I have ActiveAdmin set up to manage the users on the site, and Friendly_id for readable urls. When I go to /admin/users, it throws this error:

Undefined method `per' for #<User::FriendlyIdActiveRecordRelation:0x007fdb61a38d30>

How friendly_id is set up in the user model:

class User < ActiveRecord::Base
  #...
  extend FriendlyId
  friendly_id :name, use: :slugged
end

The only resource I could find for the conflict between these 2 gems is this question ActiveRecord::ReadOnlyRecord when using ActiveAdmin and Friendly_id which seems like a different issue and the solution doesn't work in my case. Any suggestions on how to resolve this?


Solution

  • I figured out that it's actually not the problem with friendly_id but with will_paginate as mentioned here https://github.com/gregbell/active_admin/issues/670. Switching to kaminari for pagination solves the issue for me.