From b2e6b76870b2c7dc4088f4ec0fa576cc48dd5fea Mon Sep 17 00:00:00 2001 From: f Date: Fri, 6 Oct 2023 10:16:47 -0300 Subject: [PATCH] fix: no usar post relation --- app/services/post_service.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/services/post_service.rb b/app/services/post_service.rb index d59bc8c0..0d989871 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -7,8 +7,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do # # @return Post def create - self.post = site.posts(lang: locale) - .build(layout: layout) + self.post = Post.build(site: site, locale: locale, layout: layout) post.usuaries << usuarie params[:post][:draft] = true if site.invitade? usuarie @@ -29,8 +28,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do def create_anonymous # XXX: Confiamos en el parámetro de idioma porque estamos # verificándolos en Site#posts - self.post = site.posts(lang: locale) - .build(layout: layout) + self.post = Post.build(site: site, locale: locale, layout: layouts) # Los artículos anónimos siempre son borradores params[:draft] = true @@ -118,12 +116,16 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do end end + # @return [Symbol] def locale params.dig(:post, :lang)&.to_sym || I18n.locale end + # @return [Layout] def layout - params.dig(:post, :layout) || params[:layout] + site.layouts[ + (params.dig(:post, :layout) || params[:layout]).to_sym + ] end # Actualiza los artículos relacionados según los métodos que los