1

I need to create a nested custom page inside a resource.

The route should be like this:
/admin/quizzes/:id/my_custom_page

The problem is that we can't use belongs_to in ActiveAdmin::Page.

I could create the route manually of course, but would be great if the AA could handle this for us.

The documentation says nothing and the code is not so simple. :(

Any suggestion?

Theo B
  • 351
  • 1
  • 3
  • 12

1 Answers1

2

You can use member_action:

ActiveAdmin.register Quiz do

  member_action :my_custom_page, method: :get do
  end

end

And this will generate a route at /admin/quizzes/:id/my_custom_page

Reference

Rodrigo
  • 5,435
  • 5
  • 42
  • 78
  • So obsviously... :P But do you know how to attach a `Page` instance to this `member_action`? Thanks! – Theo B Jan 29 '15 at 21:24
  • This action will render the view under the path `app/views/admin/quizzes/my_custom_page.html.erb` – Rodrigo Jan 29 '15 at 21:28
  • Yep! But could we have a `Page` instance instead? Thus we could take benefit of AA's dsl. – Theo B Jan 30 '15 at 16:01
  • `member_action` does exactly what `Page` does, but related to a model. That is what you need, don't? – Rodrigo Jan 30 '15 at 17:02
  • There are [some features](http://activeadmin.info/docs/10-custom-pages.html#available_features) that couldn't be used when working with .erb (unless you include some modules). – Theo B Feb 01 '15 at 03:20