如何在 Rails 夹具中将数据库列设置为空字符串?
How do I set a database column to the empty string in a Rails fixture?
我在 Postgres 中有一个 varchar 列,在我的 Rails schema.rb
中定义为 t.string
我想将其设置为空(零长度)字符串,而不是 NULL。
试试这个:
fixture_1:
my_column: <%= '' %>
不起作用 - 它被保存为 NULL。
如何将其设置为空白字符串?
请试试这个
fixture_1:
my_column: ""
我在 Postgres 中有一个 varchar 列,在我的 Rails schema.rb
中定义为t.string
我想将其设置为空(零长度)字符串,而不是 NULL。
试试这个:
fixture_1:
my_column: <%= '' %>
不起作用 - 它被保存为 NULL。
如何将其设置为空白字符串?
请试试这个
fixture_1:
my_column: ""