I have the following two lines in default routes
match '/:controller/:action'
match '/*path' , :to => 'map#catch_all'
So the issue is, when user hit the valid controller and invalid action name like /user/aaaa then got and exception of “Unknown action” because the route got catched by the first line of above mentioned routes.
I can’t change the order of the above lines either.
Any help??
All comments are appreciated. Thanks in Advance.
In production you should not allow the user to access not explicitly allowed actions. You should enumerate all available action, or use resource to allow the restful paths automatically. This will solve your problem.
Also, if unmatched url is entered, then the 404 message will appear to the user, which is the right way of handling this.
UPDATE:
In your ApplicationController you can implement the
method_missing(method, *args)method, to handle all the non-existing action calls which may come from the wildcarded routes.But be aware, that this catches all method call which is not existing, and this can cause problem with debugging for example in case of a typo.