Skip to content
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

Closed
alopes opened this issue Jun 15, 2011 · 7 comments
Closed

No Ransack::Search object was provided to search_form_for! #3

alopes opened this issue Jun 15, 2011 · 7 comments

Comments

@alopes
Copy link

alopes commented Jun 15, 2011

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:

@ernie
Copy link
Contributor

ernie commented Jun 22, 2011

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.

@ernie ernie closed this as completed Jun 22, 2011
@eweiser
Copy link

eweiser commented May 9, 2012

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?

@ernie
Copy link
Contributor

ernie commented May 9, 2012

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.

@eweiser
Copy link

eweiser commented May 9, 2012

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.

@railsfactory-nitin
Copy link

Hey Ernie
i got same error

########No Ransack::Search object was provided to search_form_for!##########
while upgrading spree extension from spree 0.60 to spree 1.1 .........................How to replace meta _search.

@leofrozenyogurt
Copy link

I did this in my application controller

before_filter :set_search

def set_search
@search=Product.search(params[:q])
end

worked like a charm

@merlin2049er
Copy link

Very nice! This is what I needed as well! Now how do I keep the bootstrap styling for the search box?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants