-
-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No Ransack::Search object was provided to search_form_for! #3
Comments
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 |
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 ########No Ransack::Search object was provided to search_form_for!########## |
I did this in my application controller before_filter :set_search def set_search 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? |
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:
2: <%= search_form_for @q do |f| %>
3: <%= f.label :title_cont %>
4: <%= f.text_field :title_cont %>
5:
Trace of template inclusion: app/views/application/_header.html.erb, app/views/layouts/application.html.erb
The text was updated successfully, but these errors were encountered: