这是一个新手问题,但我试图通过我的ruby控制器重定向到我的博客。该博客位于/ public / blog,但我现在只是在我的/ index上有一个空白屏幕,没有HTML内容。
这是我的home_controller.rb文件:
class HomeController < ApplicationController
before_filter :dash_board_path
def index
if current_user
redirect_to @dash_board
#else
# render :layout => "home"
end
end
def blog
current_path = request.fullpath
redirect_path = current_path.gsub("/blog" , "/index")
render :text => redirect_path and return
redirect_to redirect_path
end
end
我还应该补充一点 - 博客应该在网站上查看 - mysite.com上应该有博客。
真的很感激任何帮助。
答案 0 :(得分:0)
我认为博客方法的最后一行不会被执行,因为在渲染文本后你已经获得了and return
。因此重定向实际上并未发生。