Question

I'm using ActiveAdmin to deploy my project. And I had some problem when I was developing. I had some database table, e.g: "Worker", "Product", "Task". I wanted to create a page to search on those table with many situation.

I created a simple page:

ActiveAdmin.register_page "my page" do
content do
    panel "Search details" do
        panel "By Name" do
            render :partial => "form"
        end
    end
end 
end

And this is _form.html.erb

<form action="" method="post">
<input type="text" value="" name="taskid">Task ID</input>
<input type="text" value="" name="productid">Product ID</input>
<input type="text" value="" name="workerid">Worker ID</input>
<input type="submit" value="Submit"/>
</form>

But I don't know how can I call a controller from a form? (which controller was defined) And How can I render or show the result to the content area of "my_page" in Activeadmin from a controller?

Anyone may help me? plz!

Was it helpful?

Solution

Design the form such that it uses the existing active admin filters and displays the results accordingly. You may want to look at the HTML of your filter forms (using firebug), in order to get the required params, and the submit action. Here is the partial which I use to search my User model (constructed from user filters):

<div class="panel_contents">
  <form method="get" id="q_search" class="filter_form" action="/admin/users" accept-charset="UTF-8">
    <div class="filter_form_field filter_string">
      <label for="q_email" class=" label">Search User Email</label><br/>
      <input type="text" name="q[email_contains]" id="q_email" />
      <input type="submit" value="Go" name="commit" id="q_submit" />
    </div>
  </form>
</div>

and displays the result in the existing format. You don't need to design new views for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top