大家好,为了提供一些背景信息,我正试图向 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 变量合并到查询值中的地方时遇到了困难。提前感谢大家!![]()