使用友好_id宝石时 - 您可以忽略某些路线,例如 /about /toction吗?
我正在使用Rails应用程序中使用Friendly_id Gem,以便能够在site.com/ormanisation-name上查看组织
。友好的_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'
是否可以完全忽略这些路线,还是我需要用其他东西前缀?
I'm using the friendly_id gem in a Rails application, to be able to view organisations at site.com/organisation-name
The problem is that I have a few static pages like "About" and "Contact" at site.com/about and friendly_id assumes these pages should point to a record, hence I get this error.
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'
Is there a way to ignore these routes at all, or do I need to prefix them with something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是简单地重新排序我的路线,以将静态页面路由放在我的组织路线上的定义上: -
The solution was to simply reorder my routes to put the static page routes above my organisations route definition:-