How can I have an Active Admin nested and non-nested resource view?
activeadmin, ruby-on-rails
Solution
I think the best way now is to pass in the "optional" option:
ActiveAdmin.register Transactions do
belongs_to :user, :optional => true
...
end
This way, you'll get to access all Transactions from the main navigation menu as well as the nested view under a particular User.
If you want to find more, you can refer to the source code under:
https://github.com/gregbell/active_admin/blob/0.4.x-stable/lib/active_admin/resource.rb
Line 131
def include_in_menu?
super && !(belongs_to? && !belongs_to_config.optional?)
end
Problem
A user has_many transactions. I have active admin currently set to nest the transactions under user for basic CRUD using belongs_to :user in admin/transactions.rb. I also, however, need a top level view for transactions that shows a subset of transaction records that span across users. How can I accomplish this second part?