gazay / gon

Your Rails variables in your JS
MIT License
3.05k stars 184 forks source link

Why do my objects only contain ID strings after transmitting via gon? #266

Open asfarley opened 3 years ago

asfarley commented 3 years ago

I'm having a strange problem: previously, the gon gem was working for me to pass an array of objects to the browser. Here's the assignment:

gon.frames = @job.sequence.frames.sort_by(&:n)

Previously, this assignment resulted in the gon.frames variable containing a list of Javascript dictionaries/objects:

{id: 11, user_id: 12, sequence_id: 13, sequence_list_id: 3, complete: false, …}

Now, it contains only an ActiveRecord ID or something like that:

"#<Frame:0x00007f25035e47d0>"

I've made some changes in my code, mainly running bundle update and things like that, but nothing that would intentionally change how this work. However, there was a wide enough set of changes from updating the gems that it's hard to isolate the source of this change.

Is gon responsible for deciding how to convert something into Javascript? What would cause gon to convert into the format that only includes an identifier, rather than the dictionary of values?

asfarley commented 3 years ago

Am I understanding the CI test results correctly? It looks like this gem isn't passing for any rubies beyond 2.4.10

asfarley commented 3 years ago

Not sure what was happening here, but I rolled back to ruby 2.6.1 and it seemed to fix my problems.