Rails Admin生成错误的SQL查询

时间:2014-10-09 16:18:47

标签: ruby-on-rails activerecord model rails-admin acts-as-commentable

所以我有Service模型使用Comment gem有很多acts_as_commentable_with_threading

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

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

这是宝石生成的架构:

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不存在   第1行:SELECT&#34;评论&#34;。* FROM&#34;评论&#34;在哪里&#34;评论&#34;。&#34;服务......


如何解决此错误?

0 个答案:

没有答案