Searching in Rails 3
Here is the situation: I have the need to search for specifics or generals, much like expedia.com or your local library catalog search.
In that there are fields that may or may not be filled out based on the individual need. It acts much like an "advanced search page". I have all of that code done for the models/controller and such and have it setup with a Searches controller along with matching model and views.
The question that I have is there a way to cut down 开发者_如何学Gothe amount of parameters posted to GET so that the url isn't search?search[:a]=""+search[:b]=""+search[:c]="x"... plus the unicode checkmark. I only want the filled out fields to be shown in the response link especially minus the checkmark.
cbarton
You should probably look at an external search service rather than trying to reinvent the wheel with various search parameters.
Solr is an open source search engine that you can plug in to your rails models using 'acts_as_solr':
gem install acts_as_solr
script/plugin install git://github.com/mattmatt/acts_as_solr.git
def Article < ActiveRecord::Base
acts_as_solr :fields => [ :title, :body ]
...
You then need to edit ./config/solr.yml in your rails project to connect to a Solr server.
If you're deploying with Heroku it's really easy: http://docs.heroku.com/full-text-search
Otherwise take a look at WebSolr
精彩评论