You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to add basic search and export functionality to the application. We'll start by allowing admin users to search for an community program by name, organization, or school.
We'll use Ransack to power the search and allow users to export the results as a CSV.
CommunityProgramSearch
create app/searches/application_search.rb
create app/searches/community_program_search.rb that inherits from ApplicationSearch
#new takes a set of parameters and creates an internal ransack search @query for them
#results calls query.results and adds any needed includes, etc (eager loading)
#csv calls #results.each and returns a CSV
Admin::SearchController
#index action that only renders the form if no parameters are present, otherwise uses CommunityProgramSearch and passes the results to the view (and renders form)
#export action that uses the CommunityProgramSearch #as_csv method that returns the results as a CSV.
app/views/admin/search_controller/index.html.erb
view as outlined in image
"Export as CSV" button sends along the search parameters to search_controller#export
The text was updated successfully, but these errors were encountered:
We want to add basic search and export functionality to the application. We'll start by allowing admin users to search for an community program by name, organization, or school.
We'll use Ransack to power the search and allow users to export the results as a CSV.
CommunityProgramSearch
app/searches/application_search.rb
app/searches/community_program_search.rb
that inherits from ApplicationSearch#new
takes a set of parameters and creates an internal ransack search@query
for them#results
callsquery.results
and adds any needed includes, etc (eager loading)#csv
calls#results.each
and returns a CSVAdmin::SearchController
#index
action that only renders the form if no parameters are present, otherwise uses CommunityProgramSearch and passes theresults
to the view (and renders form)#export
action that uses the CommunityProgramSearch#as_csv
method that returns the results as a CSV.app/views/admin/search_controller/index.html.erb
search_controller#export
The text was updated successfully, but these errors were encountered: