在 C 中
def index
@search = Article.search(params[:search])
@articles = @search.all # load all matching records
# @articles = @search.relation # Retrieve the relation, to lazy-load in view
# @articles = @search.paginate(:page => params[:page]) # Who doesn't love will_paginate?
end
在 V 里
<%= form_for @search, :url => articles_path, :html => {:method => :get} do |f| %>
<%= f.label :title_contains %>
<%= f.text_field :title_contains %><br />
<%= f.label :comments_created_at_greater_than, 'With comments after' %>
<%= f.datetime_select :comments_created_at_greater_than, :include_blank => true %><br />
<!-- etc... -->
<%= f.submit %>
<% end %>