Supersedes https://github.com/thoughtbot/administrate/pull/1006, which needed a rebase and some conflict fixing.