开发者

Command to use inside the controller's action logic to determine the route that caused that action to be invoked?

开发者 https://www.devze.com 2022-12-09 21:50 出处:网络
I used rake routes to print out all of the routes in my application. What I found is that a couple of routes map to the same controlle开发者_高级运维r/action combination.

I used rake routes to print out all of the routes in my application.

What I found is that a couple of routes map to the same controlle开发者_高级运维r/action combination.

So in my action I would like to display which route was actually used to track down where everthing is coming from.

I tried just rendering params.inspect as text:

render :text => params.inspect

But I don't get the route information in the hash.

Is there some other command to reveal the currently used route from within the action?


I think you can use

request.url or params[:action] or params[:controller] depending on what you need.


request.url

This will tell you the route that caused your current action to be invoked.

0

精彩评论

暂无评论...
验证码 换一张
取 消