从Rails中的URL删除语言环境参数

问题描述:

在使用使用子域的应用程序时,我不得不使用rails url助手,而不是路径助手(在某些情况下),因此必须将domain选项作为参数传递.

I'm having to use rails url helpers, rather than path helpers (in some cases) as I'm working with an app that uses subdomains, so am having to pass the domain option as a parameter.

但是,这导致链接呈现为:

However this is causing the links to render as:

http://sub.domain.dev/the-page?locale=zh-CN

我尝试在应用程序控制器中使用以下内容的变体,但无济于事:

I've tried using variations of the following in the application controller, to no avail:

def default_url_options(options={})
  { :locale => :en }
end

如何删除该语言环境参数?

How do I remove that locale parameter?

我正在使用RefineryCMS.

I'am using RefineryCMS.

奇怪,但对于我这种情况的任何人:

Odd, but for anyone in my situation:

在将RefineryCMS与引擎一起使用时,即使未使用语言环境,并且其他引擎生成了预期的网址,也要进行以下修复:

When using RefineryCMS with engine, even though locale is not being used, and other engines produce the expected urls, the fix was to set:

# config/initializers/refinery/i18n.rb
Refinery::I18n.configure do |config|
  config.enabled = false
end