【发布时间】:2013-06-25 12:43:23
【问题描述】:
我正在创建特定于另一个模型的模型(最终将使用 Mongoid 嵌入到父模型中)。现在我只是想弄清楚如何命名它们。我已经看到它是双向的,所以我不知道该怎么做:
单数:
models/
post.rb
post/
comment.rb
comment/
happy_comment.rb
class Post
class Post::Comment
class Post::Comment::HappyComment < Post::Comment
复数:
models/
post.rb
posts/
comment.rb
comments/
happy_comment.rb
class Post
class Posts::Comment
class Posts::Comments::HappyComment < Posts::Comment
对后者的好处是可以有Posts 和Comments 模块用于包裹每个子模型:
module Posts
module Comments
class HappyComment < Comment
命名这些子模型的正确方法是什么?
【问题讨论】:
-
我更喜欢复数形式。
-
为什么更喜欢复数形式?
-
Andrew:
comments的文件夹名称比comment更好。
标签: ruby-on-rails ruby