I want to have a search widget/filter feature on a custom page using active admin to provide a look-up feature. Using the action_items I have my own action and form that renders the search page. On the search page the 'filters' that I need to show include text fields of the 'Parent' resource and a drop down list of the Parent's Parent. The association is as follows
Class MyChildResource
belongs_to :myParentResource
Class MyParentResource
attr_accessible :name, :close_to_place, :date
has_many :myChildResources
belongs_to :myGrandParentResource
class MyGrandParentResource
has_many :myParentResources
In the active admin Resource
ActiveAdmin.register MyChildResource do
action_item :only=>:index do
link_to("Look Up Availability", search_admin_myChildResources_path)
end
collection_action :search do
# do something here similar to the 'filter' feature like filter on myparentresource.date as date
filter on myGrandParentResource as drop down
filter on myParentResource.close_to_place as string
end
end
Do I have to write my own custom meta_search features? I would be fine even if I have to write own search queries, based on the input that the user gives, but my problem is that how do I display the drop down values from the parent's parent model and/or leverage the power of active admin filters.
I read something similar in this question,How to add a filter to Active Admin dashboard? , but it's a hack and it definitely does not answer the question of displaying a list