2
votes

I want to add search functionality for a couple of my models on the Active Admin Dashboard page. How do I do that?

For a regular model I can do that using "filter", but how do I do that on Dashboard view. What are the methods available within section and ActiveAdmin::Dashboards.build?

1

1 Answers

9
votes

Adding how I did it (following advice from Sjors), so that someone else may find it useful:

in dashboards.rb:

  section "Search User", :priority => 4 do
    div do
      render "search_user"
    end
  end

in views/admin/dashboard/_search_user.html.erb (Copied HTML of the user filter using firebug):

<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 Email:</label>
      <input type="text" name="q[email_contains]" id="q_email" />
      <input type="submit" value="Go" name="commit" id="q_submit" />
    </div>
  </form>
</div>