Adding forms to ActiveAdmin custom pages
11 May 2016 | railsActiveAdmin is an administration framework for Ruby on Rails applications. It allows to easily create admin pages to manage rails entities, offering out-of-the-box CRUD functionality. Sometimes, however, you need some bit of funcionality that is out of scope of a single resource.
The solution is to use custom pages, which are not tied to a single entity. The documentation explains how to add content and actions to custom page, but not forms. In my case, I had to create a custom page containing a very simple form, with a single text-field input and a submit button. Once the button is clicked, some action that depends on the value in the form had to take place.
While ActiveAdmin uses Formtastic for forms generation in the create/edit pages, it is not available in custom pages. Instead, you have to use Arbre to generate the form HTML. This also means
that you may not use Formastics’s constructs such as f.inputs
or f.actions
in your form.
See below for a sample source code:
Comments