皆さん、こんにちは。背景を説明しますと、posts テーブルのスキーマに meta_tag_id という新しいカラムを追加しようとしています。PostController のパラメータに格納したいデータを渡すところまでできています。参考までに、d/rails s のログから抜粋したものを以下に示します。
Started POST "/posts" for 127.0.0.1 at 2022-09-16 06:08:19 +0000
Processing by PostsController#create as */*
Parameters: {"raw"=>"Another dummy reply, for testing purposes.", "unlist_topic"=>"false", "category"=>"5", "topic_id"=>"23", "is_warning"=>"false", "archetype"=>"regular", "typing_duration_msecs"=>"4500", "composer_open_duration_msecs"=>"11534", "featured_link"=>"", "shared_draft"=>"false", "draft_key"=>"topic_23", "meta_tag_id"=>"summary", "nested_post"=>"true"}
ここで達成したいことは、meta_tag_id パラメータ(↑)を posts テーブルの別カラムに挿入することです。参考までに、posts テーブルにレコードを挿入する際の SQL クエリのサンプルログを以下に示します。
Post Create (1.1ms) INSERT INTO "posts" ("user_id", "topic_id", "post_number", "raw", "cooked", "created_at", "updated_at", "sort_order", "last_editor_id", "last_version_at", "word_count", "baked_at", "baked_version") VALUES (1, 23, 7, 'Another dummy reply, for testing purposes.', '<p>Another dummy reply, for testing purposes.</p>', '2022-09-16 06:08:22.283658', '2022-09-16 06:08:22.283658', 7, 1, '2022-09-16 06:08:22.293786', 6, '2022-09-16 06:08:22.283601', 2) RETURNING "id"
皆さんが正しい方向性を示していただけると幸いです。Ruby に慣れていないため、新しいカラムの追加と meta_tag_id 変数をクエリの値に組み込むために変更すべき箇所を見つけるのに苦労しています。前もって感謝します! ![]()