Rails fixture with jsonb postgres column

By Ryan Romanchuk
On

Given t.jsonb "data", default: {}, null: false, you can use the > operator to make construction easier

# test/fixtures/blobs.yml
video:
  key: /static/l35/master.m3u8
  title: Video Number One
  description: Video number one. Video number one.
  content_type: application/vnd.apple.mpegurl
  data: >
    {
      "thumbnail_key": "/static/l35/thumbnail.jpg",
      "aspect": "9x16"
    }

image:
  key: /static/one.jpg
  title: Image Number One
  description: Image number one. Image number one.
  content_type: image/jpeg
# app/models/blob.rb
class Blob < ApplicationRecord
  store_accessor :data, :thumbnail_key, :aspect, :geo_location
  # ....
end
talk