How to add a filter to Active Admin dashboard?

前端 未结 1 1875
南方客
南方客 2021-01-22 14:39

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\", bu

相关标签:
1条回答
  • 2021-01-22 15:33

    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>
    
    0 讨论(0)
提交回复
热议问题