Ive done a lot of searching on this and found lots of topics on what
search tools to use but couldnt find something re: how you generally
implement search into your project regardless of the choice of tool
I want users to be able to do a basic search and if they want supply
some extra conditions. I return the results and the user can further
filter those results by checking boxes, entering min max values etc. The
results are filtered instantly as happens instantly via ajax like
kayak.com without reloading the page(great site for airtickets by the
way) does. Im just wondering generally how i go about this. As you will
find out I dont have the vaguest of ideas on how.
Assuming i have a products model
Do I create a search model with no db attached (im expecting a lot of
searches and encouraging users to use the refine function - i dont
expect saving searches to be useful as per a railscast i saw)? within
this i create some methods such as (excuse the semi pseudo code cant
remember exact syntax)
Product.find(:all with some_conditions)
I assume ill have a form_tag for my search field and optional condition
fields. This will be on my products index view.
Where should the form_tag url link to? To products controller? cretae a
search method over there?
@search_results_of_products = Search.search(params[:search_query]
What about when i wnat users to be able refine the results even further.
Do I need to another form for this use? Would it link back to the search
function i defined earlier and ammend the code or would i create a new
method called refine? Would I basically just hit the db again but with
the new “more refined” terms or do I use ruby to just get rid of the
unwanted results from the ones i found previously.
Lots of questions. Im sorry. If you know of a good primer on this Id be
greatful. Id like to see how code is organised.