ActiveAdmin...how to set up MVC? (custom pages,actions,views)

I’m having trouble setting up a good MVC structure while using ActiveAdmin. Has anyone here set up a good MVC file structure using activeadmin? Registering resources (my existing models) is not a problem. The problem is when I have custom pages, actions, views that exist only in activeadmin, which I need. It’s gets tangled quickly and doesn’t seem to follow an MVC pattern (for example controller actions and views are shown in the same file).

There should be a pretty simple process to follow for MVC + activeadmin…but I can’t find it…and I have googled a lot, read the activeadmin.info site, browsed github, stackexchnage, and so on. I think I could really benefit from hearing about how someone else set up MVC for activeadmin custom pages/actions/views. Please let me know if you have any insight, best practices, tips, links, anything. It’s hard to believe the most used admin gem is not MVC capable and I’m really hoping someone can point me in the right direction. Thanks!

There should be a pretty simple process to follow for MVC + activeadmin…but I can’t find it

If there is, I’m not aware of it. ActiveAdmin is supposed to be “one size fits most” admin interfaces. You use their DSL to configure the resource, forms, and controller.

Maybe you could use concerns to break things up into several files if that’s what you’re after? I haven’t tried.

In cases where we’ve needed to do something significantly different than ActiveAdmin provides, we’ve simply created regular rails controllers and views and linked to them from within ActiveAdmin’s menu system. That menu goes away when you navigate to those custom areas, though. We were okay with this for an admin area.

@derekprior thanks. I may have to go the route you suggested…linking out of activeadmin to a separate controller/action. The only problem is I need to bring over / make available a “selection” from activeadmin. That is, a subset of users selected by the admin. I’m sure there must be a way to make that happen, but I am not sure if it will be via an instance variable of the user class. I’ll have to explore that. The situation is getting a bit complex, unfortunately. Thanks for your take – it’s very helpful to hear how you handled it.

Update…in app/admin/students.rb

ActiveAdmin.register Student do
  index do
    # display all students, selectable column
  end
  batch_action :show_selected, :method => :post do |selection|
    @students = Student.find(selection)
    render :partial => "admin/engage/index", :locals => {:students => @students }
  end
end

And in the partial (app/views/admin/engage/_index.html.erb):

<h1>Selected Students</h1>
<% students.each do |student| %>
	<li><%= student.first_name %> <%= student.last_name %></li>
<% end %>

This is the only thing I have been able to get working that allows selecting a group of students and going to another view to display the selection. The problem is I lose all trace of activeadmin (menus, formatting, links, everything). Has anyone here solved this problem before, or have any clues on what I’m missing, or next steps? I really just want to make that selection above and go to a custom page controller in ActiveAdmin and have the selection available to me, but I haven’t been able to find a way to do that. (I want to go to a custom page because I’m going to be mixing data on that page from several models, not just the Student model.)