Rails redirect_to 的两种写法哪个好?

chenge · January 17, 2013 · Last by windxj replied at January 18, 2013 · 1785 hits

redirect_to '/dashboard'

or

redirect_to(dashboard_path)

后一种有什么明显的好处么?dashboard_path 似乎是 resource 生成的动态方法,增加了理解的难度。

我觉得吧 应该是为了实现 即使 URL 修改,只要 controller action 不变,代码就不用修改 这样一个效果吧。。

这和讨论动态、静态;相对、绝对一样吧

个人喜欢下面的,因为你的 URL 可能是变化的,如果文件夹名称变了呢?但是下面的是动态的~

You need to Sign in before reply, if you don't have an account, please Sign up first.