0

なので、 gemを使ったServiceモデルが多いです。Commentacts_as_commentable_with_threading

class Service < ActiveRecord::Base
  has_many :comments, dependent: :destroy
end

class Comment < ActiveRecord::Base
  # Boilerplate gem generated code
end

gem が生成するスキーマは次のとおりです。

create_table "comments", force: true do |t|
    t.integer  "commentable_id",          default: 0
    t.string   "commentable_type"
    t.string   "title"
    t.text     "body"
    t.string   "subject"
    t.integer  "user_id",                 default: 0,   null: false
    t.integer  "parent_id"
    t.integer  "lft"
    t.integer  "rgt"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "cached_votes_total",      default: 0
    t.integer  "cached_votes_score",      default: 0
    t.integer  "cached_votes_up",         default: 0
    t.integer  "cached_votes_down",       default: 0
    t.integer  "cached_weighted_score",   default: 0
    t.integer  "cached_weighted_total",   default: 0
    t.float    "cached_weighted_average", default: 0.0
  end

サービスにアクセスしようとすると、Rails 管理者が間違ったクエリを生成しています。を見てhas_many :commentsジャンプします。

http://localhost:5000/admin/service/999

PG::UndefinedColumn: エラー: 列 comments.service_id が存在しません LINE 1: SELECT "comments".* FROM "comments" WHERE "comments"."service...


このエラーを修正するにはどうすればよいですか?

4

0 に答える 0