我的项目中有许多用户可用。每个用户有不同的主页。而且我还有一个默认主页。我的实际代码是在这里..导轨 - 重定向问题
requested_url = "/limited/username" #It is constantly changing.
redirect_to(requested_url || :action => "index", :controller => "demo")
因此,它重定向页面像这样http://localhost:3000/demo/index?%2Flimited=username
。但是,实际上我需要重定向的url,像这样http://localhost:3000/limited/username
。
如果requested_url
为空,那么它会正确重定向。 (http://localhost:3000/demo/index
)。但是,如果它不是空的,它会错误地重定向。
请告诉我这里有什么问题?
演示控制器不是常用的控制器。 “demo/index”和“/限制/用户名”都是分开的。抱歉!。我不喜欢使用if语句。我稍微修改了我的代码,如redirect_to(requested_url ||“demo/index”)。现在,我的问题解决了。感谢您记住运营商的优先权。 –