【问题标题】:How to name the has_many thru join model between User and Blog?如何命名用户和博客之间的has_many thru join 模型?
【发布时间】:2012-01-10 16:31:03
【问题描述】:

我的母语不是英语,但如果你是,你会如何命名这个 Rails ActiveRecord 连接模型“???”以语义方式?

User has_many :blogs, through: ???
User has_many ???

??? belongs_to :user
??? belongs_to :blog

Blog has_many :owners, class_name: 'User', through: ???
Blog has_many ???

“Blogger”之类的东西听起来不太好:用户 has_many :bloggers

【问题讨论】:

    标签: ruby-on-rails activerecord active-relation


    【解决方案1】:

    我想我会选择“作者身份”。对我来说,“博客”是写博客的过程。当然,重要的是所选词对您来说是有意义的,因为在与他们一起工作时,您需要记住它的含义。

    【讨论】:

    • 不错的一个!唯一的问题可能是以类似方式与用户链接的后续模型。 BlogAuthorship 或 BlogOwnership 可能是替代方案。
    • 甚至是多态所有权连接模型。
    猜你喜欢
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-05
    • 1970-01-01
    • 2017-06-29
    相关资源
    最近更新 更多