Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用轨道路径(nil)渲染404_Ruby On Rails_Routes - Fatal编程技术网

Ruby on rails 使用轨道路径(nil)渲染404

Ruby on rails 使用轨道路径(nil)渲染404,ruby-on-rails,routes,Ruby On Rails,Routes,假设我们有一条路线: get "foo/:foo_param" =>"blahblah" , :as=>"rails_some_route" 在我看来,我写道: "rails_some_route_path('aa')" this give proper url => 'foo/aa' 但是如果视图(另一个.slim文件)意外包含 “a href={rails\u some\u route\u path(nil)}”。 视图本身渲染为404 只有路由应该断开,但奇怪的是页面

假设我们有一条路线:

get "foo/:foo_param" =>"blahblah" , :as=>"rails_some_route"
在我看来,我写道:

"rails_some_route_path('aa')" this give proper url => 'foo/aa'
但是如果视图(另一个.slim文件)意外包含
“a href={rails\u some\u route\u path(nil)}”
。 视图本身渲染为404

只有路由应该断开,但奇怪的是页面本身呈现404

考虑\u所有\u请求\u本地
对于开发人员而言为false

应用程序控制器

unless config.consider_all_requests_local
    rescue_from ActionController::RoutingError, :with => :render_404
    rescue_from ActionController::UnknownController, :with => :render_404
    rescue_from ActionController::UnknownAction, :with => :render_404
    rescue_from Error404, :with => :render_404
    rescue_from GoshPosh::Platform::Errors::AuthError do
      redirect_to login_path({:rd=>request.path})
    end
  end
路线:

  unless Rails.application.config.consider_all_requests_local
    match '*not_found', :to => 'web_application#render_404'
  end

您是否援救异常并在应用程序控制器中显示404页面?我添加了援救该页面的代码。。但这仅适用于生产模式