You can sort of hit both issues with 1 fix app/controllers/search_controller. Rb class SearchController || params:search.strip. Empty?
@search = Product. Search do fulltext params:search end @products = @search. Results end @products end end # /app/views/search/index.
Haml - if @products. Empty? Your search did not return any results.
- else # display the results or do whatever you want to do when something is actually found Basically what I'm proposing is that you start SearchController#index by setting products to an empty array. If the search param is passed in we check it's stripped result (white space removed) and see if there's anything left If the user has searched a bunch of spaces, then strip will have reduced that to nothing and the search will not be run In the event the stripped version of the search param does actually have something in there (aka probably valid search text) then do the search and set products to the set of results Finally, return products In your view, you can then check the products array to see if it's empty or not. If it's empty then either the user searched for whitespace (bogus) or their search didn't return anything... so you can take appropriate action based on that.
You can sort of hit both issues with 1 fix. # /app/controllers/search_controller. Rb class SearchController Nil?
|| params:search.strip. Empty? @search = Product.
Search do fulltext params:search end @products = @search. Results end @products end end # /app/views/search/index. Haml - if @products.
Empty? Your search did not return any results. - else # display the results or do whatever you want to do when something is actually found Basically what I'm proposing is that you start SearchController#index by setting @products to an empty array.
If the search param is passed in we check it's stripped result (white space removed) and see if there's anything left. If the user has searched a bunch of spaces, then strip will have reduced that to nothing and the search will not be run. In the event the stripped version of the search param does actually have something in there (aka probably valid search text) then do the search and set @products to the set of results.
Finally, return @products. In your view, you can then check the @products array to see if it's empty or not. If it's empty then either the user searched for whitespace (bogus) or their search didn't return anything... so you can take appropriate action based on that.
Added an explanation. – SizzlePants Nov 13 at 0:22 Strange, it doesn't recognize the method strip. I get the error undefined method strip' for nil:NilClass`.
– JustinRoR Nov 13 at 1:47 1 I added a nil check params:search. Nil? Can you try that?
I feel like this is a hack... so even if it ultimately works, I bet someone with more expertise knows a more correct way. – SizzlePants Nov 13 at 2:08 This did work. I will play around with it but this gets me on the right track, thank you.
– JustinRoR Nov 13 at 2:12 no prob. Good luck -- just starting w/ Sunspot myself :) – SizzlePants Nov 13 at 2:14.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.