I have a Rails application which uses ransack to make search. I think my question its simple, I like to make one form search work with multiple models.
There is my code:
SearchController:
class SearchController < SuperSiteController
def index
@q = Page.ransack(params[:q])
@result = @q.result(distinct: true)
end
def search
index
render :index
end
end
My form:
<%= search_form_for @q, url: search_path, html: { method: :post } do |f| %>
<%= f.search_field :name_cont, placeholder: "BUSCAR", required: true %>
<% end %>
I didn't find anything in documentation about the best way to do that. How can I do this?