使用 friendly_id gem 时 - 你可以忽略某些路由,例如 /about /contact 吗?

When using the friendly_id gem - can you ignore certain routes like /about /contact?

我在 Rails 应用程序中使用 friendly_id gem,以便能够在网站上查看组织。com/organisation-name

问题是我在网站上有一些静态页面,如“关于”和“联系”。com/about 和 friendly_id 假设这些页面应该指向一条记录,因此我得到了这个错误。

ActiveRecord::RecordNotFound in OrganisationsController#show
can't find record with friendly id: "about"

routes.rb

  resources :organisations, path: "", except: [:index, :new, :create] do
    resources :posts
  end
  get '/organise', to: 'home#organise'
  get '/privacy', to: 'home#privacy'
  get '/about', to: 'home#about'
  get '/terms', to: 'home#terms'

有没有办法完全忽略这些路由,或者我是否需要在它们前面加上其他内容?

解决方案是简单地重新排序我的路由,将静态页面路由置于我的组织路由定义之上:-

  get '/organise', to: 'home#organise'
  get '/privacy', to: 'home#privacy'
  get '/about', to: 'home#about'
  get '/terms', to: 'home#terms'

  resources :organisations, path: "", except: [:index, :new, :create] do
    resources :posts
  end