Repository navigation
Conversation
- 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
left a comment
There was a problem hiding this comment.
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:
-
When the transaction arrived.
update_resourceonly gainedActiveRecord::Base.transaction/ActiveRecord::Rollbackin 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. -
Return value. 3.5.2's
update_resourcereturns the result ofsave_resource. The override returns whateverrun_update_callbacksreturns. Nothing in ActiveAdmin or InheritedResources reads it, but an app's customupdateaction 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
-
CSV header sanitizing. ActiveAdmin 3's
CSVBuilder#buildruns the header names throughsanitize(the formula-injection guard) as well as the rows. Ourbuildoverride still gets row sanitizing through ActiveAdmin'sbuild_row, but writes the header without it. Header names are usually developer-defined, so the risk is low, butsanitize(encode(c.name, options))would keep it identical to upstream.
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:
activeadmin ~> 3.0.update_resourcesaves the way ActiveAdmin 2 did. ActiveAdmin 3 wraps the save inActiveRecord::Base.transactionand raisesActiveRecord::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:
ransack-mongoid ~> 1.0and require it instead ofransack. The Gemfile's GitHub pin goes.Gem files: listed with
Dir.globinstead ofgit 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:
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+.
_equals,_greater_than,_less_than), and date ranges use_gteq/_lteq.Release 3.0.0: README requirements (and how to stay on 2.x for ActiveAdmin 2), a CHANGELOG entry, and the version.
Breaking changes
ransack-mongoid1.x. Remove anyransack-mongoidline from your Gemfile.Testing
Locally, all 31 examples pass on:
RuboCop is clean, and
gem buildproduces activeadmin-mongoid-3.0.0 withactiveadmin ~> 3.0,ransack-mongoid ~> 1.0andmongoid >= 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.