Ruby/Rails-用两个词命名的模型(命名约定问题) [英] Ruby/Rails - Models Named with Two Words (Naming Convention Issues)
本文介绍了Ruby/Rails-用两个词命名的模型(命名约定问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这确实是有关命名约定的问题.
This is really a question about naming conventions.
我有一个名为PromotedEvents的模型
I have a model called PromotedEvents
该文件称为promoted_events.rb
The file is called promoted_events.rb
我用以下方法创建了表格
I created the table with:
create_table :promoted_events do |t|
现在我在创建任何东西时遇到问题,所以我想知道使用两个单词的模型是否存在问题
Now I'm having problems creating anything, so I'm wondering if theres some problem using model with two words
在控制台中输入并尝试
a = PromotedEvents.new
a = Promoted_Event.new
a = promoted_event.new
,并不断出现nameerror : uninitialized constant
错误
有什么想法吗?
推荐答案
您的课程应该是单数.
在文件promoted_event.rb
a = PromotedEvent.new
这篇关于Ruby/Rails-用两个词命名的模型(命名约定问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文