Is it possible to map your routes inside of Controllers? I prefer having my routes defined near my controller actions.
If your motivation is to co-locate routing rules with associated controller actions then I don't believe that is possible in Rails. The controller actions are executed post-routing so the ability to direct any routing behavior (such as it is) in the controller layer is limited to redirect_to
which is just syntactic sugar for HTTP's "302 moved". Hardly a satisfactory routing strategy.
Rack middleware (within Rails) or the Sinatra framework more tightly couples routing and actions in code. Perhaps this is what you're looking for?
Please hve a look my code . First dont define anything about your controller in rount.rb .
Then if your enter in browser "http://localhost:3000/users/my_action" .
Then write a following code in your controller .
Class UsersController < ....
def my_action
if request.get? somrthing your code ...... end
if request.post? something your code ...... end
end
end