gregbell/active_admin — pull request #620 by jbarket (2011-10-14 16:52:14+00:00)
Title: Added Authorization Layer, Adapter for CanCan, option for automatic nesting of belongs_to resources in menus

If settings.nested_associations is true, resources that belong_to the current
resource will be nested underneath it automatically. In other words, if
Comments belongs_to Posts, you'll see a menu item for Comments only when
viewing a specific Post, and that menu item will take you to the Comments
related to that post.

/posts/ <- No Comments link
/posts/1 <- /posts/1/comments as the link

All of these items accept the normal menu configuration options like label,
parent and display.

There may be depth related limitations, but I believe these line up with
the same depth limitations currently found in ActiveAdmin and
InheritedResource.

In addition to this, there is also now a function on the Resource class that will allow you to determine all belongs_to relationships when given a specific resource's name. This is capable of giving parents, children and a combination of these. It may be useful in the future for automatically creating a table_for belongs_to resources on show pages, in a somewhat similar fashion to RailsAdmin.

Added AuthorizationAdapter layer. auto_link, default actions, menus,
et cetera use new methods to determine if the current user is authorized
to view them.

The default AuthorizationAdapter returns true for all.

Also included is a CanCan adapter. Simply change
config.authorization_adapter_class to ActiveAdmin::CanCanAdapter, and these
actions will be checked via your defined Abilities.