从Rails中的URL删除语言环境参数 [英] Removing locale parameter from url in rails

查看:46
本文介绍了从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

这篇关于从Rails中的URL删除语言环境参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆