модель
class PushNotificationRequest < ApplicationRecord
serialize :details
миграция
class CreateNotificationRequests < ActiveRecord::Migration[5.2]
def change
create_table :notification_requests do |t|
t.references :order, references: :spree_orders, index: false
t.string :key
t.json :details
t.string :type
t.timestamps
end
end
end
Создание данных на консоли
PushNotificationRequest.create(order: Spree::Order.last, details: {a: 2})
Mysql странное хранилище
mysql> select * from notification_requests;
+----+----------+------+----------------+-------------------------+-----------+---------------------+---------------------+
| id | order_id | key | details | type | status | created_at | updated_at |
+----+----------+------+----------------+-------------------------+-----------+---------------------+---------------------+
| 7 | 19 | NULL | "---\n:a: 2\n" | PushNotificationRequest | INITIATED | 2019-01-09 13:45:40 | 2019-01-09 13:45:40 |
+----+----------+------+----------------+-------------------------+-----------+---------------------+---------------------+
Столбец details
хранится как какая-то странная строка, а не как правильный json
Я использую mysql 8.0.12 и rails 5.12
Что-то мне не хватает?