Skip to content

Commit

Permalink
building new record puts in the relation array. woah
Browse files Browse the repository at this point in the history
  • Loading branch information
GBH committed Nov 29, 2017
1 parent 1b43db6 commit 2ff5983
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/comfy/admin/blog/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ def load_post
end

def build_post
layout = (@site.blog_posts.order(:created_at).last.try(:layout) || @site.layouts.order(:created_at).first)
@post = @site.blog_posts.new(post_params)
@post.published_at ||= Time.zone.now
@post.layout ||= (@site.blog_posts.last.try(:layout) || @site.layouts.first)
@post.layout ||= layout
end

def post_params
Expand Down

0 comments on commit 2ff5983

Please sign in to comment.