diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 4ef6b3b..635cfe2 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -31,8 +31,7 @@ class PostsController < ApplicationController def new authorize Post @site = find_site - # TODO: Implementar layout - @post = @site.posts.build(lang: I18n.locale) + @post = @site.posts.build(lang: I18n.locale, layout: params[:layout]) end def create diff --git a/app/models/post_relation.rb b/app/models/post_relation.rb index 9e0df2e..40ccaa9 100644 --- a/app/models/post_relation.rb +++ b/app/models/post_relation.rb @@ -57,7 +57,7 @@ class PostRelation < Array def build_layout(layout = nil) return layout if layout.is_a? Layout - site.layouts[layout || :post] + site.layouts[layout.try(:to_sym) || :post] end # Devuelve una colección Jekyll que hace pasar el documento diff --git a/app/models/site.rb b/app/models/site.rb index 48ebb6e..72d9cce 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -206,8 +206,7 @@ class Site < ApplicationRecord # @return Array def everything_of(attr, lang: nil) posts(lang: lang).map do |p| - # XXX: Tener cuidado con los métodos que no existan - p.send(attr).try :value + p.send(attr).try(:value) if p.attribute? attr end.flatten.uniq.compact end