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

编程入门 行业动态 更新时间:2024-10-24 16:26:47
本文介绍了从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:

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删除语言环境参数

本文发布于:2023-11-01 11:34:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549233.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:环境参数   语言   Rails   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!