why Marshal.dump a relation obejct would faile

452 views
Skip to first unread message

李永博

unread,
Sep 5, 2019, 1:57:15 AM9/5/19
to Ruby on Rails: Talk
with a special scope Marhal.dump(result) wolud cause a faile


*** TypeError Exception: no _dump_data is defined for class Proc

```
(byebug) result.class
BatchCloth::ActiveRecord_Relation
(byebug)  Marshal.dump(result)
*** TypeError Exception: no _dump_data is defined for class Proc

(byebug) puts result.to_sql
SELECT DISTINCT batch_cloths.*, batch_cloths.created_at FROM "batch_cloths" INNER JOIN "product_variants" ON "product_variants"."id" = "batch_cloths"."product_variant_id" LEFT OUTER JOIN "quality_control_tasks" ON "quality_control_tasks"."id" = "batch_cloths"."quality_control_task_id" AND "quality_control_tasks"."deleted_at" IS NULL INNER JOIN "reception_items" ON "reception_items"."id" = "quality_control_tasks"."qcable_id" AND "reception_items"."deleted_at" IS NULL AND "quality_control_tasks"."qcable_type" = 'ReceptionItem' INNER JOIN "receptions" ON "receptions"."id" = "reception_items"."reception_id" AND "receptions"."deleted_at" IS NULL INNER JOIN "factories" ON "factories"."id" = "receptions"."factory_id" AND "factories"."deleted_at" IS NULL WHERE "batch_cloths"."deleted_at" IS NULL AND "batch_cloths"."company_id" = 2 AND "factories"."uuid" = 'df9dbf09-fd10-4546-a511-e103bed8a6e4' AND "batch_cloths"."sample" = FALSE AND "product_variants"."variant_category" = 0 AND "batch_cloths"."stock_status" IN (0, 5, 6, 1) ORDER BY batch_cloths.created_at DESC

```

Frederick Cheung

unread,
Sep 18, 2019, 5:19:23 AM9/18/19
to Ruby on Rails: Talk
On Thursday, September 5, 2019 at 6:57:15 AM UTC+1, 李永博 wrote:
> with a special scope Marhal.dump(result) wolud cause a faile
>
>

Proc objects just can’t be dumped - this is a limitation of ruby.

Fred
Reply all
Reply to author
Forward
0 new messages