在我的模型中,我有:
class Listing < ApplicationRecord
...
has_rich_text :description
...
end
在我的seeds.rb 中:
@listing = Listing.new(
title: 'CODE VEIN',
price: 59.99 * 100,
description: "<p>#{Faker::Lorem.paragraphs(number: 30).join(' ')}</p>",
seller_id: seller.id,
release_date: Date.parse('Sep 26, 2019'),
status: :active,
esrb: 'MATURE'
)
Listing.description 出现为零,导致我的 NOT NULL 约束出错。
我已经用 pry 进行了调试,并尝试了@listing.description.body= text
or @listing.description.body = ActionText::Content.new(text)
,两者仍然导致listing#description 为零。
这是一个仅限 API 的项目,但我在前端反应应用程序中使用 Trix RTE。是否有特定的方法来播种rich_text 列?