【问题标题】:LocomotiveCMS has_many/belongs_to not workingLocomotiveCMS has_many/belongs_to 不工作
【发布时间】:2014-01-22 02:02:37
【问题描述】:

由于某种原因,我无法让 has_many/belongs_to 关系起作用。嵌套内容类型不会显示在父级中。这是我所拥有的:

app/content_types/news_photos.yml

- article:
    label: News articles
    type: belongs_to
    target: news_articles

app/content_types/news_articles.yml

- news_photos:
    label: News photos
    type: has_many
    target: news_photos
    class_name: news_photos
    inverse_of: news_article
    required: false
    hint: A description of the field for the editors
    localized: false
    ui_enabled: true

感谢您的帮助!

【问题讨论】:

  • 这似乎是命名约定中的错误。尝试一些教程中的生成器示例并进行比较。

标签: locomotivecms


【解决方案1】:

我不确定您是否找到了解决方案,但问题实际上在于命名。 has_many 定义应该有 inverse_of: article

inverse_of 的值应该是其他模型中具有belongs_to 关系的属性的名称,在本例中为news_photos

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多