使用rail_some_route_path(nil)呈现404

时间:2012-08-28 18:22:32

标签: 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_some_route_path(nil)}"。 视图本身呈现为404。

只有路线应该被打破,但奇怪的是页面本身会呈现404

对于dev

consider_all_requests_local为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

0 个答案:

没有答案