I have done something along these lines using a database store.  I
dont use SearchLogic, but build my searches using anonymous scope and
also use Thinking Sphinx.

I have a search model with attributes as below:

Where the search was made from:
    t.string  "user"
    t.string  "model_name"
    t.string  "controller"
Details of the search
    t.text    "search_filter"
    t.string  "search_type"
    t.string  "search_field"
    t.integer "page"
    t.integer "per_page"
    t.string  "name"

user holds the id for the user making this search.
search_filter contains the search fields serialized, so it can save
fields for searches against any model.  I also save the controller
since I may be searching the same model from different controllers and
want to keep separate filters.
Search field contains the search term if it is a Sphinx search, and
search_type defines if the search is normal or sphinx
I have a name field which I have not yet implemented but which is
intended eventually to allow users to store pre defined named
searches.
The user is also allowed to change the per_page setting so I save that
too.

To use the search in the controller requires three standard method
calls as below:
         @search=Search.set_search(@user,Product,params)
@filt...@search.filter
@produc...@search.do_search

set_search does an update or create for this user,model,controller.
It uses the params hash to get the controller and to serialize the
current filter fields.

The do search method in the search model makes a call to a method
which I have called 'filtered' in each model being searched (so the
actual search is local to each model).  I havnt used search_logic, but
I guess with that you wouldnt need to have a specific method in each
model.  In the 'filtered' method in the model being searched, I check
to see if I am doing a normal database search, or if it is  Sphinx
search (my form has a search box as well as filter fields).

For the filter fields, I use an instance of the model being searched
which makes building the search form really easy.

It may not be the best approach, but it works for me and I have done
my best to minimise and standardise the code in the controller.
I hope it may at least give you some ideas or provoke some other
responses.

Tonypm

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to