with_scope
###ロコモティブ CMS での使用について質問があります。
まずmovies
、完全なフィールドを持つモデル があり、そのうちの 1 つがfilm_etats
withで呼び出されtype: belongs_to
ます。
別のモデルfilm_etats
があり、のetat
フィールドtype: string
と の別のフィールドmovies
がありtype: has_many
ます。
これで問題なく動作します - 自分のデータを見ることができます - しかし、やりたいことは情報をフィルタリングすることです。
Locomotive CMS のドキュメントには、 https ://doc.locomotivecms.com/docs/tags#with_scope があります。
これが最初の例です。
{% with_scope author: 'John Doe' %}
{% for post in content_type.posts %}
{{ post.title }}
{% endfor %}
{% endwith_scope %}
だから私はこれをしました:
{% with_scope film_etats.etat: 'Production' %}
{% for film in contents.film %}
etat du film : {{film.film_etats.etat}}
{% endfor %}
{% endwith_scope %}
しかし、それは機能せず、私が望むものは型エラーです:nilの未定義メソッド「エントリ」:NilClass
私のモデル映画
title_film => type (string)
film_etats => type belongs_to
私のモデル film_etats
etat => type(string)
films => type(has_many)
ありがとう