From 1ad4eeccb4e93b5ccaa2ffdfca3f8b1c71f324af Mon Sep 17 00:00:00 2001 From: f Date: Fri, 6 Oct 2023 10:14:13 -0300 Subject: [PATCH] fix: no usar PostRelation para instanciar un nuevo Post #7537 obligaba a cargar casi todo el sitio en memoria y muchas lecturas de disco --- app/controllers/posts_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 77354be1..078e16f8 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -54,9 +54,11 @@ class PostsController < ApplicationController def new authorize Post - @post = site.posts(lang: locale).build(layout: params[:layout]) - breadcrumb I18n.t('loaf.breadcrumbs.posts.new', layout: @post.layout.humanized_name.downcase), '' + layout = site.layouts[params[:layout].to_sym] + @post = Post.build(locale: locale, layout: layout, site: site) + + breadcrumb I18n.t('loaf.breadcrumbs.posts.new', layout: layout.humanized_name.downcase), '' end def create