I have a table of \"posts\" with attributes that include title and body.
posts_controller.rb:
class PostsController < A
Although this is not a direct answer to your question, here are some resources that may help you as you are learning about search and getting it implemented in your Rails app.
A Simple search form
Advanced search form
Searching with AJAX
Powerful search functionality with the Sunspot gem
List of the most popular search tools for Ruby
---------------UPDATE----------------
Elasticsearch has been growing in popularity due to some modern awesomeness that it has, such as instant indexing. It has a ruby gem named tire. Definitely worth a look.
Elasticsearch
Tire
---------------UPDATE 2----------------
Tire has been retired, and has been replaced by Elasticsearch-ruby