Skip to content

Support ActiveAdmin 3 and Ransack 4, and prepare 3.0.0 - #174

Merged
jdguzman merged 4 commits into
masterfrom
jd/3.0
Dec 2, 2026
Merged

jdguzman merged 4 commits into
masterfrom
jd/3.0

Conversation

@jdguzman

@jdguzman jdguzman commented Dec 2, 2026

Copy link
Copy Markdown
Member

Adds ActiveAdmin 3 support and prepares 3.0.0. ActiveAdmin 3 requires Ransack 4, and its Mongoid support now comes from ransack-mongoid 1.0 (released on RubyGems), which becomes a runtime dependency. Use 2.x with ActiveAdmin 2.

Changes

  • ActiveAdmin 3:

    • Require activeadmin ~> 3.0.
    • update_resource saves the way ActiveAdmin 2 did. ActiveAdmin 3 wraps the save in ActiveRecord::Base.transaction and raises ActiveRecord::Rollback, neither of which exists without ActiveRecord, so every admin update failed.
    • counter_cache_col? returns false. ActiveAdmin 3 asks associations for counter caches, which Mongoid doesn't have.
  • Dependencies:

    • Depend on ransack-mongoid ~> 1.0 and require it instead of ransack. The Gemfile's GitHub pin goes.
    • Require Mongoid 7.5 or later, the oldest that supports Rails 7.
  • Gem files: listed with Dir.glob instead of git ls-files, so the gem also loads when vendored without git (for example in a Docker build).

  • Tests and CI: a matrix over Ruby 3.1–4.0:

    Rails Mongoid
    7.0 7.5, 8.1
    7.1 8.1
    7.2 8.1
    8.0 8.1

    That's 24 jobs, excluding Ruby 3.1 with Rails 8.0. Mongoid 7.5 stops at Rails 7.0, Mongoid 8.1 at Rails 8.0, and Rails 8.0 needs Ruby 3.2+.

    • The specs use ActiveAdmin 3's filter names. It removed the MetaSearch aliases (_equals, _greater_than, _less_than), and date ranges use _gteq / _lteq.
    • Rails 8 draws routes lazily, and ActiveAdmin registers its resources then, so the default-filter spec loads routes first.
    • The test app uses Devise 4.9 on Rails 7.0 and 7.1. With Devise 5 there, sign-in fails because the password parameter reaches Devise's strategy empty; Devise 5 works on Rails 7.2 and 8.0. This only affects the test setup.
  • Release 3.0.0: README requirements (and how to stay on 2.x for ActiveAdmin 2), a CHANGELOG entry, and the version.

Breaking changes

  • Requires ActiveAdmin 3.x and Ransack 4, through ransack-mongoid 1.x. Remove any ransack-mongoid line from your Gemfile.
  • Requires Mongoid 7.5 or later.
  • ActiveAdmin 3's own filter changes, listed in the CHANGELOG, also apply.

Testing

Locally, all 31 examples pass on:

Rails Mongoid Ruby
7.0 7.5 3.1, 3.3, 4.0
7.0 8.1 3.3
7.1 8.1 3.3
7.2 8.1 3.1, 3.3
8.0 8.1 3.2, 3.3, 4.0

RuboCop is clean, and gem build produces activeadmin-mongoid-3.0.0 with activeadmin ~> 3.0, ransack-mongoid ~> 1.0 and mongoid >= 7.5, < 9.

These changes have also been running in a Rails 7.1 / Mongoid 8.1 application, through a vendored copy, with its full RSpec and Cucumber suites green.

- Require activeadmin ~> 3.0.
- update_resource: ActiveAdmin 3 wraps the save in ActiveRecord::Base.transaction
  and raises ActiveRecord::Rollback, which don't exist without ActiveRecord.
  Save the way ActiveAdmin 2 did.
- counter_cache_col?: ActiveAdmin 3 asks has_many associations for counter
  cache columns; Mongoid associations have none.
- List gem files with Dir.glob instead of git ls-files, so the gem also loads
  when vendored without git (e.g. in a Docker build).
ActiveAdmin 3 requires Ransack 4. ransack-mongoid 1.0, now on RubyGems,
provides Mongoid support for it, so make it a runtime dependency, require
it instead of ransack, and drop the GitHub pin from the Gemfile.

Mongoid 7.5 is the oldest version that supports Rails 7.
- CI matrix: Ruby 3.1-4.0 with Rails 7.0 on Mongoid 7.5 and 8.1, and Rails
  7.1, 7.2 and 8.0 on Mongoid 8.1 (Mongoid 7.5 stops at Rails 7.0; Rails 8.0
  needs Ruby 3.2+). The Gemfile defaults to Rails 8.0.
- Specs use ActiveAdmin 3's filter names: _eq, _gt and _lt instead of the
  removed MetaSearch aliases, and _gteq/_lteq for date ranges.
- Rails 8 draws routes lazily, and ActiveAdmin registers its resources then,
  so the default-filter spec loads routes first.
- Devise 4.9 on Rails 7.0 and 7.1. With Devise 5 there, sign-in in the test
  app fails because the password parameter reaches Devise's strategy empty;
  Devise 5 works on Rails 7.2 and 8.0.
- README: 3.0.0 requirements, and how to install 2.x for ActiveAdmin 2.
- CHANGELOG for 3.0.0, including ActiveAdmin 3's own filter changes.
- Version 3.0.0.

@boie0025 boie0025 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I checked the overrides against ActiveAdmin 3.0, 3.2, 3.5.0 and 3.5.2. They hold up across the whole ~> 3.0 range, and the smoke spec covers editing a post. A few small things, none blocking:

  1. When the transaction arrived. update_resource only gained ActiveRecord::Base.transaction / ActiveRecord::Rollback in 3.5.2; 3.0 through 3.5.1 already save exactly like this override. The override is still right everywhere, but the code comment and the CHANGELOG ("ActiveAdmin 3 wraps the save...") would be more accurate saying 3.5.2.

  2. Return value. 3.5.2's update_resource returns the result of save_resource. The override returns whatever run_update_callbacks returns. Nothing in ActiveAdmin or InheritedResources reads it, but an app's custom update action might. Returning the save status would match:

    def update_resource(object, attributes)
      object = assign_attributes(object, attributes)
      status = nil
      run_update_callbacks(object) { status = save_resource(object) }
      status
    end
  3. CSV header sanitizing. ActiveAdmin 3's CSVBuilder#build runs the header names through sanitize (the formula-injection guard) as well as the rows. Our build override still gets row sanitizing through ActiveAdmin's build_row, but writes the header without it. Header names are usually developer-defined, so the risk is low, but sanitize(encode(c.name, options)) would keep it identical to upstream.

@jdguzman
jdguzman merged commit 6a995b5 into master Dec 2, 2026
25 checks passed
@jdguzman
jdguzman deleted the jd/3.0 branch December 2, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants