ruby on rails 多元化有帮助吗? [英] ruby on rails pluralization help?

查看:43
本文介绍了ruby on rails 多元化有帮助吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
如何覆盖 rails 命名约定?

我的应用程序将使用西班牙语.说我要脚手架生成 actividad.复数将是 actividades 所以我希望表和控制器被命名为......我该怎么做?

My app is gonna be in spanish. Say I want to scaffold generate actividad. the plural would be actividades so I want the table and the controller to be named that .... how can I do this?

推荐答案

在 config/environment.rb 中放入以下代码:

Put the following code in config/environment.rb:

Inflector.inflections do |inflect|
  inflect.irregular 'actividad', 'actividades'
end

在控制台(脚本/控制台)测试代码:

Test the code in the console (script/console):

'actividad'.pluralize
'actividades'.singularize

可在此处找到更多详细信息:http://codeidol.com/other/rubyckbk/Web-Development-Ruby-on-Rails/Understanding-Pluralization-Rules/

这篇关于ruby on rails 多元化有帮助吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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