我正在做一个Rails项目,它使用了一个通用的路线,主要用于渲染一个Angular前端页面。因为这个包罗万象的路由已经在项目中了,所以我现在已经失去了点击/rails/info/routes的能力,这对我来说是比较方便的。
下面是我的routes.rb的相关部分:
Rails.application.routes.draw do
match "/delayed_job" => DelayedJobWeb, :anchor => false, via: [:get, :post]
namespace :api, format: false, defaults: {format: :json} do
.....
get '*path' => 'base#not_found'
end
namespace :admin, format: false, except: [:show] do
.....
root 'home#index'
end
devise_for :users
get 'styleguide' => 'styleguide#index'
get '*path' => 'bootstrap#index'
root 'bootstrap#index'
end发布于 2016-02-13 02:19:27
弄明白了-对于遇到这种情况的任何人,你可以在请求不是以/rails开头的地方添加一个contstraint:
get '*path' => 'bootstrap#index', constraints: -> (req) { !(req.fullpath =~ /^\/rails\/.*/) }https://stackoverflow.com/questions/35369428
复制相似问题