From fb56ef2d74879cc375d2cf87b55897a0026b8067 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 1 Oct 2020 09:17:04 -0300 Subject: [PATCH] Al filtrar PostRelation devolver otra --- app/models/post_relation.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/post_relation.rb b/app/models/post_relation.rb index ba13785..1e5c528 100644 --- a/app/models/post_relation.rb +++ b/app/models/post_relation.rb @@ -115,6 +115,14 @@ class PostRelation < Array end] end + # Como Array#select devolviendo una relaciĆ³n + # + # @return [PostRelation] + alias array_select select + def select(&block) + PostRelation[*array_select(&block)] + end + # Intenta guardar todos y devuelve true si pudo def save_all(validate: true) map do |post|