what will be the code for 'search' option in page and after that
search result will be shown in next page

Hi Joe,

you are asking something very wide, i suggest you go ahead and read
some tutorials and books (try to find some.
there are MILLIONS of examples on how to implement a search mechanism.

If you are asking for full text search then you can use ferret.
You can find a brief tutorial on how to use it here

most of my experience has been with ferret, but I've seen production
sites are also using sol/acts_as_solr and Sphinx/sphincter:

also tsearch/Postgres



The issue that I have found with the search requirement, is in
actually identifying the type of search that you want to carry out.
Start by narrowing down the specifics of what you want to achieve, and
then if you need help on that, ask again for someone to point you in
the right direction. If you just want to be able to select a single
record from the database, then the CRUD type of approach is to list
all records in the index action, giving each record a unique link
based on its id. Clicking the link then sends that id to the show
method. Rails routes and particularly the restful resource follows
this approach so that it is easy to build the paths. I am just
getting my head around this fully myself.

Regarding search in general, the types of things I consider when
needing to implement search or look up are the following.

1. What sort of result am I looking for. A list, or a single
2. What fields/information are relevant to the search
3. If there are multiple fields, should they be searched
simultaneously, or only one at a time.
4. If the reuslt is to be a list then you probably want a filter that
will sift the data by some search criteria.
5. A single result will either need a unique key, or will need a
means of choosing the actual required result from a list or drop down
6. IS the search to be interactive using an ajax call, or will just
return the results via a new page (your request suggest you are just
looking for the latter.)

I have tried a number of types of lookups for my applications, I am
tending to home in on two main types.

The first is a filter on an index page. The simplest of these is
basic pagination, then adding to that the ability to filter by a
specific field, eg supplier name, or location, or type etc. That
field may be free text field or a drop down, and can offer partial
field look up. Building the filter into a form, allows the fields to
be passed to the server.

The second approach I use is to offer a display of a blank record,
with auto-complete fields for the fields I wish to allow to be used as
lookups. Then typing into any of those fields will dynamically return
a list of possible matches for the user to select. Write your own
selection method in the controller to update the whole object.

I havn't tried using Ferret yet, since it seems to me that it builds a
system wide search for indexing, which for my requirements is overkill
and added complexity. If I am missing a point about Ferret then maybe
someone might enlighten me.

Define your search requirement more tightly, and then if you are still
looking for help in how to implement it, post a more specific request
and I am sure you will get more help.