ruby-on-rails - Rails 5 - 如何防止 Rails 将语言环境添加到构造路径上的 URL?
问题描述
升级到 Rails 5.2 后,(编辑:使用)当我使用从(如)构造的路径时,"5.2.0.rc1"
我现在已被添加到我的 url。如何阻止 Rails 将语言环境添加到我的 url?我永远不需要它们。?locale=en
path_helper
login_path
我的控制器:
``` #home_controller.rb
def index
redirect_to login_path
end
```
应用程序.rb
```
require_relative 'boot'
require 'rails/all'
Bundler.require(*Rails.groups)
module MyApp
class Application < Rails::Application
config.assets.initialize_on_precompile = false
config.generators do |g|
g.fixture_replacement :rspec
g.fixture_replacement :factory_bot
end
end
end
```
怎么了:
它把我重定向到localhost:3000/login?locale=en
解决方案
似乎在 Rails 5 中的某个地方,path_helper
在构建 URL 时不再省略可选参数,如 locale。唯一要做的就是等待 PR 修复它。看起来已经做了很多,但不清楚它们是否已合并或修复是否存在于5.2.1
https://github.com/rails/rails/pull/32526
推荐阅读
- java - 如何通过 Java 中的硒测试提供对维基百科中建议结果(下拉菜单)的点击?
- angular - Angular 7中的多个共享级联组合框组件
- deployment - 在 Slack 上部署 Watson
- docker - 无法从主机连接到 docker 容器内的 .net 核心网站
- java - how to add an image to my sql server database
- c# - 文件上传默认路径
- php - 使用 MailChimp API 将电子邮件地址添加到列表时出错
- javascript - Vue-multiselect如何进行两个输入
- r - Spread data based on multiple key variables
- javascript - Bootstrap: $('#myModal').modal('show'); causes screen to go black