Browse Source

Merge remote-tracking branch 'origin/main' into feature/215

pull/219/head
みてるぞ 1 month ago
parent
commit
74057cbce9
2 changed files with 30 additions and 2 deletions
  1. +2
    -2
      backend/app/controllers/posts_controller.rb
  2. +28
    -0
      backend/db/migrate/20260107034300_make_title_nullable_in_posts.rb

+ 2
- 2
backend/app/controllers/posts_controller.rb View File

@@ -80,7 +80,7 @@ class PostsController < ApplicationController
# TODO: URL が正規のものがチェック,不正ならエラー
# TODO: URL は必須にする(タイトルは省略可).
# TODO: サイトに応じて thumbnail_base 設定
title = params[:title]
title = params[:title].presence
url = params[:url]
thumbnail = params[:thumbnail]
tag_names = params[:tags].to_s.split(' ')
@@ -121,7 +121,7 @@ class PostsController < ApplicationController
return head :unauthorized unless current_user
return head :forbidden unless current_user.member?

title = params[:title]
title = params[:title].presence
tag_names = params[:tags].to_s.split(' ')
original_created_from = params[:original_created_from]
original_created_before = params[:original_created_before]


+ 28
- 0
backend/db/migrate/20260107034300_make_title_nullable_in_posts.rb View File

@@ -0,0 +1,28 @@
class MakeTitleNullableInPosts < ActiveRecord::Migration[7.0]
def up
change_column_null :posts, :title, true

execute <<~SQL
UPDATE
posts
SET
title = NULL
WHERE
title = ''
SQL
end

def down
execute <<~SQL
UPDATE
posts
SET
title = ''
WHERE
title IS NULL
SQL

change_column_null :posts, :title, false
end
end


Loading…
Cancel
Save