Rails 可选/:locale 路由 [英] Rails optional /:locale route

查看:32
本文介绍了Rails 可选/:locale 路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的 rails 应用程序设置一个路由系统,该系统允许一个可选的路由 (/:locale) 被允许到网站的基础.

I'm trying to setup a routing system for my rails app that allows for an optional route (/:locale) to be allowed to the base of the website.

或多或少:

/en/home/将转到与/home/相同的页面/zh/people/->/people/

/en/home/ would goto the same page as /home/ /en/people/ -> /people/

我遇到的唯一问题是在路由配置中进行设置.

The only issue I'm having is setting this up in the routes config.

推荐答案

使用 scope '(:locale)' 做...end.您可以在此处查看 Agile Web Development with Rails 中的示例:

Use scope '(:locale)' do...end. You can see an example from Agile Web Development with Rails here:

http://intertwingly.net/projects/AWDwR4/checkdepot-30/section-15.1.html

这篇关于Rails 可选/:locale 路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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