siempre encontrar la plantilla
This commit is contained in:
parent
33713af201
commit
1f377437e4
2 changed files with 4 additions and 2 deletions
|
@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_template(site)
|
def find_template(site)
|
||||||
id = params[:template_id] || params[:template]
|
id = params[:template_id] || params[:template] || params.require(:post).require(:layout)
|
||||||
site.templates.find do |t|
|
site.templates.find do |t|
|
||||||
t.id == id
|
t.id == id
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,9 @@ class PostsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@site = find_site
|
@site = find_site
|
||||||
@lang = find_lang(@site)
|
@lang = find_lang(@site)
|
||||||
@post = Post.new(site: @site, front_matter: post_params.to_hash, lang: @lang)
|
@template = find_template(@site)
|
||||||
|
@post = Post.new(site: @site, lang: @lang, template: @template)
|
||||||
|
@post.update_attributes(post_params)
|
||||||
|
|
||||||
if @post.save
|
if @post.save
|
||||||
redirect_to site_posts_path(@site, lang: @lang)
|
redirect_to site_posts_path(@site, lang: @lang)
|
||||||
|
|
Loading…
Reference in a new issue