LocomotiveCMS has_many/belongs_to not working

254 Views Asked by At

For some reason I cannot get the has_many/belongs_to relationship to work. The nested content type does not show up in the parent. Here is what I have:

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

Thanks for the help!

1

There are 1 best solutions below

0
On

I'm not sure if you got to the solution but the issue is in fact in naming. The has_many definition should have inverse_of: article

The value of inverse_of should be the name of the attribute that has the belongs_to relation in other model, in this case news_photos.