ActiveAdmin with Rails 5 and Mongoid 6

ActiveAdmin with Rails 5 and Mongoid 6

One of our most recent projects uses ActiveAdmin with Mongoid 5 and Rails 4.2. Since Rail 5’s release, we’d been eyeing up some of the new features, including the use of ActionCable without backports. Unfortunately, there’s a lack of support in ActiveAdmin 1.0 pre-release branches, and despite their efforts to add compatibility, the existing activeadmin-mongoid gem has not been maintained since ActiveAdmin announced out-of-the-box support for Mongoid. We took it upon ourselves to update one of our own activeadmin-mongoid gem forks and share our work with the Rails community. Our activeadmin-mongoid fork has passed internal testing, and the functionality works fine in our application. Keep in mind, however, that you should fully test your application’s activeadmin after using the unofficial fork in production. (We cannot guarantee that there are no bugs or missing functionality!)

Here are the gems we are using in production. The specific ref for activeadmin could be updated, but would require further testing, as this is the ref we have tested against.

  gem ‘mongoid’, ‘~> 6.0.0’ # Not yet working with 6.1.x branch
  gem ‘devise’
  gem ‘bootstrap-kaminari-views’
  gem ‘kaminari-mongoid’, ‘= 0.1.2’ # Lock due to activeadmin compatibility
  gem ‘kaminari’, ‘= 0.17.0’ # Lock due to activeadmin compatibility
  gem ‘activeadmin’, git: ‘’, ref: ‘6411350c8abf’
  gem ‘activeadmin-mongoid’, git: ‘’, branch: ‘nb/mongoid-6’

Reference App:

To run the reference app (github), follow these steps:

  1. Clone repo.
  2. Install bundle: bundle.
  3. Create a user from the console:
  SECRET_KEY_BASE=[secret key base for session] bundle exec rails c
  AdminUser.create(email: '[email]', password: '[password]', password_confirmation: '[password]')
  SECRET_KEY_BASE=[secret key base for session] bundle exec rails s

In this upgrade, we also had to upgrade two other Mongoid-related gems, mongoid-enum and mongoid_token. These have all been tested at a basic level, but again, there’s no warranty or guarantee of performance. We’re using these against Mongoid 6.0.x.

  gem “mongoid-enum”, git: ‘’, branch: ‘nb/mongoid-6’
  gem ‘mongoid_token’, git: ‘’, branch: ‘nb/mongoid-6’

We’d love to know if you try out these updates in your own project. If you’re interested in learning how WebVolta can build a custom application for your business, use our Contact Us page to reach out!

pin-icon phone