ThreadSky
About ThreadSky
Log In
baweaver.bsky.social
•
47 days ago
What am I missing here? It has to be something silly.
Comments
Log in
with your Bluesky account to leave a comment
[–]
lostjedakan.bsky.social
•
47 days ago
It's been a minute for me, but are you looking for as_json ?
1
1
reply
[–]
coreyja.com
•
47 days ago
Ya with to_json I feel like this is working as Id expect
to_json returns a string, and since a string is a valid JSON value we can save it to the column on its own
And as_json returns the json-flavored hash, which then gets saved to the json column as an object (assuming you start with a hash)
2
1
reply
[–]
coreyja.com
•
47 days ago
I would assume that ActiveRecord calls as_json on whatever you pass to a json column so you don’t need to call it explicitly, but I’m less sure about that
1
reply
[–]
jamesdallen.me
•
47 days ago
Not an expert but it probably just sees that second one as a string rather than a hash so it doesn’t know to do the magic casting
5
reply
Posting Rules
Be respectful to others
No spam or self-promotion
Stay on topic
Follow Bluesky's terms of service
×
Reply
Post Reply
Comments
to_json returns a string, and since a string is a valid JSON value we can save it to the column on its own
And as_json returns the json-flavored hash, which then gets saved to the json column as an object (assuming you start with a hash)