I have a search form in the header of my app and I would like to use this search form to search through multiple models within the application.
For example a request like /search?q=rails
should trigger a search through multiple models like Work
, Project
, User
and their defined attributes. I wanted to use Ransack because I already use it on the Work
model in a different area of the app.
I think I don't quite understand Ransack yet and the documentation always points out that you have to define @q = MyModel.search(params[:q])
to use it in the form search_form_for @q
. Is there a way where you don't have to define a specific model in advance? And just pass in the parameter name like search_form_for :q
?