You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expectation
When calling a localized entry through the gem, I expect that traversing the hierarchy of the model will also return entries with localized fields for that locale. That is, when calling child.parent, or child.children in a locale other than my default, I expect both the parent and the children to be returned in that locale.
I hope I'm just missing a parameter or option or configuration or something!
Observation
When we call parent records for a localized entry through the gem, the parent's fields are not localized with locale of the originally fetched entry.
It seems that child records are getting returned in the same locale as the parent though, as expected.
For example
A content model called Publication, which has a has-many references with a model called Chapter. In our Chapter model class, we have belongs_to_many :publications, and in our Publication model class we have has_many :chapters.
When we fetch a Chapter entry in French for example (chapter = Chapter.locale('fr').load.first), I see the chapter's fields in French.
When I call chapter.publication, the resulting publication's fields are in English. When I inspect the publication's locale, I see it comes back as 'en-US' (my default locale).
I do notice that calling chapter.pages (a child of chapter) provides me with page entries with fields in French.
tried passing an option of locale but got a wrong arguments error. In any case I do not see where other option keys outside the defaults are being considered in the fetch for the parent.
The text was updated successfully, but these errors were encountered:
Expectation
When calling a localized entry through the gem, I expect that traversing the hierarchy of the model will also return entries with localized fields for that locale. That is, when calling
child.parent
, orchild.children
in a locale other than my default, I expect both the parent and the children to be returned in that locale.I hope I'm just missing a parameter or option or configuration or something!
Observation
When we call parent records for a localized entry through the gem, the parent's fields are not localized with locale of the originally fetched entry.
It seems that child records are getting returned in the same locale as the parent though, as expected.
For example
A content model called
Publication
, which has a has-many references with a model calledChapter
. In ourChapter
model class, we havebelongs_to_many :publications
, and in ourPublication
model class we havehas_many :chapters
.When we fetch a
Chapter
entry in French for example (chapter = Chapter.locale('fr').load.first
), I see thechapter
's fields in French.When I call
chapter.publication
, the resultingpublication
's fields are in English. When I inspect thepublication
's locale, I see it comes back as 'en-US' (my default locale).I do notice that calling
chapter.pages
(a child of chapter) provides me withpage
entries with fields in French.However I also noticed that calling my original
chapter
in French back from its publication:chapter.publication.chapters.first
yields a chapter instance in the default locale, rather than my original entry, as described here: https://github.com/contentful/contentful_model/blob/master/lib/contentful_model/associations/belongs_to_many.rb#L38Things I tried
Calling
child.parent.locale(locale)
> does not seem to be an optionOn the
Chapter
class tried to pass an option to thebelongs_to_many
method as described here: https://github.com/contentful/contentful_model/blob/master/lib/contentful_model/associations/belongs_to_many.rbtried passing an option of
locale
but got a wrong arguments error. In any case I do not see where other option keys outside the defaults are being considered in the fetch for the parent.The text was updated successfully, but these errors were encountered: