我正在尝试设置一个仅用于开发的路由,该路由匹配除了url中包含/attachments/
的路由之外的所有内容。这可能吗?
示例:
match '*a', to: 'errors#four_oh_four', via: :all, constraints: { all: /^(?!.*attachments).*$/ } if Rails.env.development?
答案 0 :(得分:0)
基于我在这里遇到的一些帖子,我是如何解决这个问题的:
match '*a', to: 'errors#four_oh_four', via: :all, constraints: ->(req) { !req.env['REQUEST_PATH'].include?('attachments') } if Rails.env.development?
通过Rubocops:https://github.com/bbatsov/ruby-style-guide 在此处找到指南:https://github.com/rails/rails/issues/7924