mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 19:26:21 +00:00
feat: cargar el formulario del post sin decoración
This commit is contained in:
parent
a734b65a9e
commit
4876c61d10
3 changed files with 24 additions and 0 deletions
|
@ -40,6 +40,22 @@ class PostsController < ApplicationController
|
|||
render layout: false
|
||||
end
|
||||
|
||||
# El formulario de un Post, si pasamos el uuid, estamos editando, sino
|
||||
# estamos creando.
|
||||
def form
|
||||
uuid = params.permit(:uuid).try(:[], :uuid)
|
||||
|
||||
@post =
|
||||
if uuid.present?
|
||||
site.indexed_posts.find_by!(post_id: uuid).post
|
||||
else
|
||||
# @todo Usar la base de datos
|
||||
site.posts(lang: locale).build(layout: params.require(:layout))
|
||||
end
|
||||
|
||||
render layout: false
|
||||
end
|
||||
|
||||
def index
|
||||
authorize Post
|
||||
|
||||
|
|
7
app/views/posts/form.haml
Normal file
7
app/views/posts/form.haml
Normal file
|
@ -0,0 +1,7 @@
|
|||
-#
|
||||
El formulario sin ninguna decoración, para incluir dentro de otros
|
||||
elementos.
|
||||
|
||||
@param :site [Site]
|
||||
@param :post [Post]
|
||||
= render 'posts/form', site: @site, post: @post
|
|
@ -103,6 +103,7 @@ Rails.application.routes.draw do
|
|||
get :'posts/new_array', to: 'posts#new_array'
|
||||
get :'posts/new_array_value', to: 'posts#new_array_value'
|
||||
get :'posts/new_related_post', to: 'posts#new_related_post'
|
||||
get :'posts/form', to: 'posts#form'
|
||||
|
||||
resources :posts do
|
||||
get 'p/:page', action: :index, on: :collection
|
||||
|
|
Loading…
Reference in a new issue