Rails保留的类名称 [英] Rails Reserved Class Names

查看:67
本文介绍了Rails保留的类名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试创建一个名为班级"的模型(就像即将毕业的学生一样),遇到了各种各样的问题.在Rails中还要避免使用其他一些单词或类名吗?

I tried creating a model called "class" (as in a graduating class of students), and encountered all kinds of problems. What are some other words or class names to avoid in Rails?

我找到了一些链接:
http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/
http://railsforum.com/viewtopic.php?id=22242

Some links I've found:
http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/
http://railsforum.com/viewtopic.php?id=22242

推荐答案

此页面上有很长的单词列表,不可用:

This page has a very long list of words not to use:

https://reservedwords.herokuapp.com/words

因为类"作为元编程的名称非常普遍,所以我认为公认的红宝石替代品是玻璃".显然,这与您即将毕业的课堂情况有所不同,但也许仍会有所帮助.

Because 'class' comes up very commonly as a name with metaprogamming, I think the accepted ruby alternative is 'klass'. This is obviously a different context from your graduating class situation, but maybe still helpful.

这篇关于Rails保留的类名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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