开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜