I’ll use my recipe example again.
It would be nice if I could have my routes (I think) set up so that if
somebody enters a a controller that doesn’t exist a database search
runs and looks for the controller name as one of the categories (for
example the user enters http://www.com/italian). This is an existing
category in the database so it would likely then redirect to www.com/categories/italian (and from there the categories controller
would handle things).
if somebody enters a a controller that doesn’t exist a database search
runs and looks for the controller name
Is this possible without violating any “rules”?
You would probably be able to do something by catching 404 errors in
your application controller and then punting them off to a method that
tries to guess what the user meant. Google for “Rails 404” for a few
methods to try.
if somebody enters a a controller that doesn’t exist a database search
runs and looks for the controller name
Is this possible without violating any “rules”?
You would probably be able to do something by catching 404 errors in
your application controller and then punting them off to a method that
tries to guess what the user meant. Google for “Rails 404” for a few
methods to try.
Actually, no 404 catching is necessary. All you need is a catchall
route that sends ‘/:category’ off to a search action.