1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Model :

  def self.search(search)
    search_condition = "%" + seach + "%"
    find(:all, :conditions => ['title_dutch LIKE ? OR content_dutch LIKE ?', search_condition, search_condition])
  end

Controller : 

    def search
      @results = Page.search params[:search]
    end

View (layout file):

<% form_tag :controller => 'nederlands', :action => 'search', :method => 'get' do %>
              <%= text_field_tag :search, params[:search] %>
              <%= submit_tag "Search", :name => nil %> 
        <% end %> 

View (search) : 

<%= debug(@results)%>

Log entry :

Processing NederlandsController#2-pathologieen (for 127.0.0.1 at 2009-02-07 11:54:42) [POST]
  Parameters: {"search"=>"inleiding", "authenticity_token"=>"435fa58bc759e55c28a3e11072aab64cce5e9c33", "id"=>"search", "method"=>"get"}
  SQL (0.1ms)   SET NAMES 'utf8'
  SQL (0.1ms)   SET SQL_AUTO_IS_NULL=0
  PageCategory Load (0.4ms)   SELECT * FROM `page_categories` ORDER BY position

Routes :


  map.resources :nederlands, :member => {:detail => :get, :gerelateerd => :get, :album => :get, :PaginaNietGevonden => :get, :search => :get}