Hi Ernie,
I'm trying to move a search form into my website header using a partial. It works ok unless I switch to another controller while browsing the site. Do I need to pass anything extra into my search_form_for in order to render outside its related controller? As you can see I'm fairly new to rails.
Thanks for your help.
ArgumentError in Videos#show
Showing /Users/x/Documents/Development/webdev/x/app/views/application/_search.html.erb where line #2 raised:
No Ransack::Search object was provided to search_form_for!
Extracted source (around line #2):
1:
You have to set the value of @q in the controller that is eventually calling the partial. My guess is that the action you're calling the partial in is not actually setting up that instance variable the same way your first controller is.
Hi Ernie,
Sorry, I'm confused--if I want a ransack search bar on the header of every page, do I have to set @q for every controller's every action?
You'd have to handle the Ransack-required stuff in a before_filter or (ick) in the view partial itself. If you're putting a search field on every single part of the site, I'd recommend you strongly consider whether ransack is the right tool for the job, as well. You might want some sort of inverted index search setup like sphinx, solr, etc.
Thanks for such a fast response, Ernie. I'm a Rails noob and have never heard of any of these--I just found ransack by googling around. I'll check those out now.
Hey Ernie
i got same error
while upgrading spree extension from spree 0.60 to spree 1.1 .........................How to replace meta _search.
I did this in my application controller
before_filter :set_search
def set_search
@search=Product.search(params[:q])
end
worked like a charm
Very nice! This is what I needed as well! Now how do I keep the bootstrap styling for the search box?
Most helpful comment
I did this in my application controller
before_filter :set_search
def set_search
@search=Product.search(params[:q])
end
worked like a charm