【发布时间】:2011-09-09 14:11:35
【问题描述】:
我希望重定向到我的应用程序/公共文件夹中的 index.html。
def get_current_user
@current_user = current_user
if @current_user.nil?
redirect_to root_path
end
end
我如何做到这一点?
我还没有修改我的 routes.rb 中的根(它仍然被评论)
# root :to => "welcome#index"
我收到一条错误消息,提示 root_path 未定义。
如何修改 routes.rb 让 root_path 指向 public/index.html ?
【问题讨论】:
-
不要使用
root_path,而是使用redirect_to '/' -
@meagar 这是答案,不是评论,那你为什么不直接创建答案而不是评论问题呢?
-
@MBO 这不是一个答案。问题是“我该如何做 X?”我的评论是“不要,而是做 Y”。这不是 IMO 可接受的答案,我会否决其他人这样发布它。
标签: ruby-on-rails path redirect root