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

查看:74
本文介绍了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/进入同一页面 /en/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)' do ... end.您可以在使用Rails进行敏捷Web开发中查看示例:

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天全站免登陆