缩写模型的Rails非正统命名 [英] Rails unorthodox naming of models with abbreviations
问题描述
在我正在构建的应用程序中,我正在使用acts_as_tree
关联将XML文件存储在数据库中.我想将类命名为XMLElement
,但是由于大写字母是非标准的,因此这会引起麻烦.它正在从文件名xml_element.rb
寻找XMLElement
.我尝试将文件名更改为x_m_l_element.rb
,以试图欺骗它以为"XML"实际上是两个单词,但这也不起作用.我应该把它吸起来并使用名称XmlElement
代替更理想的XMLElement
,还是有解决此问题的更好方法?
In an application I am building I am storing an XML file in my database using the acts_as_tree
association. I would like to name the class XMLElement
but this throws rails off since the capitalization is non-standard. It is looking for XMLElement
from the file name xml_element.rb
. I tried changing the filename to x_m_l_element.rb
to try and trick it into thinking that "XML" was really two words, but this didn't work either. Should I just suck it up and use the name XmlElement
instead of the more ideal XMLElement
, or is there a better way around this issue?
推荐答案
对配置人员的约定.吸起来.
Convention over configuration man. Suck it up.
这篇关于缩写模型的Rails非正统命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!