#101 オリジナルの作成日時,フォームにフィールド追加

This commit is contained in:
2025-09-15 05:20:25 +09:00
parent c9bae764f7
commit cafd55bf22
6 changed files with 142 additions and 21 deletions
+7 -2
View File
@@ -69,8 +69,11 @@ class PostsController < ApplicationController
url = params[:url]
thumbnail = params[:thumbnail]
tag_names = params[:tags].to_s.split(' ')
original_created_from = params[:original_created_from]
original_created_before = params[:original_created_before]
post = Post.new(title:, url:, thumbnail_base: '', uploaded_user: current_user)
post = Post.new(title:, url:, thumbnail_base: '', uploaded_user: current_user,
original_created_from:, original_created_before:)
post.thumbnail.attach(thumbnail)
if post.save
post.resized_thumbnail!
@@ -103,10 +106,12 @@ class PostsController < ApplicationController
title = params[:title]
tag_names = params[:tags].to_s.split(' ')
original_created_from = params[:original_created_from]
original_created_before = params[:original_created_before]
post = Post.find(params[:id].to_i)
tags = post.tags.where(category: 'nico').to_a + Tag.normalise_tags(tag_names)
if post.update(title:, tags:)
if post.update(title:, tags:, original_created_from:, original_created_before:)
render json: post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }),
status: :ok
else