Before and After Filters/Functions for Rails Routes


I have an idea and I am not sure if is is already done.Right now to make url search engine friendly developers use to_param function of model class. Then they call to_s function to get the id of the elmenet. What if I want to create url for not model but for string. Lets say I create link for post controller’s search action. The only variable in the url is search_string. Si how can i create seo link for this search page. I know how to create links etc etc. but my problem is I want to call function on this string such as to_param or something like that to make seo string, also in the controller to perform a search I have to humanize this string again. So what I want is this:

In every view, I dont want to use urlizing method to make it se friendly

In every controller, I do not want to call any function to humanize string back again, this should done by router

In the router:

match ‘search/:string’ => ‘Post#search’, :as => :search, before => some_helper_function, after => some_other_helper_function

In these helper function what I will do is that i will parametrize any params I want, then I will humanize any params back again

here is the link for stackoverflow version routing - Before and After Filters/Functions for Rails Routes - Stack Overflow