Здравствуй, Хабр!
Есть код передающий в gon некоторый хэш:
gon.select_options = Product.all.to_a.inject({}) do |hash, product|
hash[product.id] = product.materials.to_a.inject({}) do
|materials_hash, material| materials_hash[material.id] = get_material_data_hash(material)
end
end
Но в итоге хэш этот пуст, хотя в БД есть записи. В чем может быть проблема?
UPD. Вот лог запросов, шо вроде бы говорит, что значения есть
ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by AdminPanelController#materials_panel as HTML
Product Load (0.1ms) SELECT "products".* FROM "products"
Material Load (0.6ms) SELECT "materials".* FROM "materials" INNER JOIN "materials_products" ON "materials"."id" = "materials_products"."material_id" WHERE "materials_products"."product_id" = ? [["product_id", 2]]
Material Load (0.3ms) SELECT "materials".* FROM "materials" INNER JOIN "materials_products" ON "materials"."id" = "materials_products"."material_id" WHERE "materials_products"."product_id" = ? [["product_id", 3]]
Material Load (0.2ms) SELECT "materials".* FROM "materials" INNER JOIN "materials_products" ON "materials"."id" = "materials_products"."material_id" WHERE "materials_products"."product_id" = ? [["product_id", 4]]