Rails路线

编程入门 行业动态 更新时间:2024-10-25 17:18:08
本文介绍了Rails路线-如何使其不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Ruby on Rails中的路由区分大小写。似乎以前有人提出过这个问题,并且它被标记为无法解决。

Routes in Ruby on Rails are case sensitive. It seems someone brought this up before, and it has been labeled will not fix.

rails.lighthouseapp/projects/8994/tickets/393-routes-are-case-sensitive

这让我感到非常不幸,因为我并不认为自己的路线区分大小写会有任何上升的空间,而在下降的空间则可能造成混乱和我认为总体上缺乏波兰语。

That strikes me as unfortunate, as I don't really see any upside on my own application for routes to be case sensitive, while on the downside it creates a potential for confusion and a general appearance of lack of polish in my opinion.

使路线不区分大小写的最佳方法是什么?

What's the best way to make my routes case insensitive?

我在Google搜索中找到了这个提示:

I found this tip on a Google search:

map.connect "web_feeds/:action", :controller => 'web_feeds', :action => /[a-z_]+/i

这很聪明,但是仍然留下了web_feeds部分网址区分大小写。但是,在没有手动输入wEb_feEds的每种可能组合的情况下,我看不出有任何类似的解决方法,但是出于多种原因,这显然是一个可怕的解决方案。

This is clever, but it still leaves the web_feeds portion of the url case sensitive. I don't see any similar way around this, however, without entering in each possible combination of wEb_feEds manually, but that is obviously a horrible solution for any number of reasons.

推荐答案

我遇到了同样的问题,并使用中间件解决了-在这里看看:

I've just has the same problem, and solved it using middleware - have a look here:

gehling.dk/2010/02/how-to -make-rails-routing-case-insensitive /

注意:这仅适用于Rails 2.3 +

Note: This only applies for Rails 2.3+

  • Carsten

更多推荐

Rails路线

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

发布评论

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

>www.elefans.com

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