重定向到404页面未找到 - rails

时间:2013-04-09 13:18:05

标签: ruby-on-rails redirect controller routes

我需要将不正确的页面重定向到404页面,目前我正在重定向到主页,我有这个:

def thirdlevel
    if something
      if something else
        render :template => "services/thirdlevel"
      else
         redirect_to "/"
      end
    else
    redirect_to "/"
  end
end

1 个答案:

答案 0 :(得分:-1)

我将error404操作添加到我的控制器,然后以这种方式引用它:

else
  render :action => "error404"
end


def error404
  @breadcrumb = [{:name => "Page not found"}]
end