Rails sharing controller functionality and menus
===

Sorry if this seems daft (not much sleep lately) but I'm trying to figure out the best way to share controller (and method) functionality between controllers without writing the same code for each one. 

Let's say I have various controllers with the same method called `search`. Inside this method I have situations for the same term for different controllers, like:

        case term
          when "beginning_parens"
           @books = Book.where("title REGEXP ? AND localeLanguage LIKE ?", '^\\([0-9]*\\)', params[:language]).not_locked.reorder(order).paginate(:page => params[:page])
          when 'search_all_caps'
           @books = Book.detect_uppercase.not_locked.reorder(order).where("localeLanguage LIKE ?", params[:language]).paginate(:page => params[:page])


Now I don't want to have to write all of that for each controller. And I'd like not to have to pass the `params[:language]`, `paginate`, etc. to each of the cases since I want each one to search by language and paginate as well. 

Or course, the instance variable would change among controllers, instead of `@books` we would have `@dvds`, `@games`, etc. 

I also find myself having to pass all the `params` in the menu links:

    = link_to 'with all CAPS', books_search_path(:term => 'search_all_caps', :language => params[:language])

And I'm sure there has to be a better way to do this. 

I'm already sharing common methods for the models with a file I call at the top of each model with `extend ModelFunctions`. This file contains methods such as `detect_uppercase` which is used above and is common for many controllers. So at least I have that part working :)

Any help would be appreciated. 