2018-01-29 22:19:10 +00:00
|
|
|
class PostsController < ApplicationController
|
|
|
|
before_action :authenticate!
|
|
|
|
|
|
|
|
def index
|
|
|
|
@site = find_site
|
|
|
|
end
|
2018-01-30 15:20:19 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
@site = find_site
|
|
|
|
@post = find_post(@site)
|
|
|
|
end
|
2018-01-31 20:29:27 +00:00
|
|
|
|
|
|
|
def edit
|
|
|
|
@site = find_site
|
|
|
|
@post = find_post(@site)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
p = post_params
|
|
|
|
|
|
|
|
# crear un array a partir de una cadena separada por comas
|
|
|
|
[:tags,:categories].each do |comma|
|
|
|
|
p[comma] = p.dig(comma).split(',').map(&:strip)
|
|
|
|
end
|
|
|
|
|
|
|
|
binding.pry
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def post_params
|
|
|
|
params.require(:post).permit(:title, :date, :tags, :categories, :content)
|
|
|
|
end
|
2018-01-29 22:19:10 +00:00
|
|
|
end
|