I tried your what you suggested, still have some issues, posting my real
models instead of docs Artist-Albums ...
@rs[:jobs] = Job.where(:id => [100254,100255]).eager(job_items: {
job_material: :fifo}).json_serializer_opts(:include => {:job_items => {:include
=> {:job_material => {:include => :fifo}}}}).all
Unexpected error while processing request: undefined method
`json_serializer_opts'
for #<#<Class:0x0000000102d928>:0x0000000101fb48>
Thanks
On Monday, 22 June 2020 08:12:30 UTC-6, Jeremy Evans wrote:
>
> On Monday, June 22, 2020 at 5:22:56 AM UTC-7, shreko wrote:
>>
>> For classic example of Eager loading fom docs:
>>
>> Artist.one_to_many :albums
>> Album.one_to_many :tracks
>> Tracks.many_to_one :lyric
>>
>>
>> artists = Artist.eager(albums: {tracks: :lyric})
>>
>>
>> In order to get full data structure json, is there a way to write
>> json_serializer_opts a bit more concise than the following
>>
>> artists.each do |artist|
>> artist.json_serializer_opts(include: :albums)
>>
>> artist.albums.each do |album|
>> album.json_serializer_opts(include: :tracks)
>>
>> album.tracks.each do |track|
>> track.json_serializer_opts(include: :lyric)
>> end
>>
>> end
>> end
>>
>
> I think the following should work:
>
> Artist.eager(albums: {tracks:
> :lyric}).json_serializer_opts(:include=>{:albums=>{:include=>{:tracks=>{:include=>:lyric}}}})
>
> If not, please let me know.
>
> Thanks
> Jeremy
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/f47f44df-5c56-4bc6-9300-011d9653adcfo%40googlegroups.com.