Skip to content

Commit ba7945f

Browse files
committed
Fix "ArgumentError: string contains null byte"
1 parent d13f275 commit ba7945f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/tasks/db.rake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def append(klass, doc)
4040
doc[:desc] ||= ''
4141
end
4242

43+
if klass == Reply
44+
doc[:body] = doc[:body].gsub("\u0000", "")
45+
doc[:body_html] = doc[:body_html].gsub("\u0000", "")
46+
end
47+
4348
item = klass.unscoped.find_or_initialize_by(id: doc[:id].to_i)
4449
item.attributes = doc.reject{ |k,v| !item.attributes.keys.member?(k.to_s) }
4550
if item.save(validate: false)

0 commit comments

Comments
 (0)