0

我在 Rails 4 上玩 RailsAdmin。我有非常简单的案例(两个模型,Event 属于 Idea)。

代码:

class Idea < ActiveRecord::Base
end

class Event < ActiveRecord::Base
  belongs_to :idea

end

架构

  create_table "events", force: true do |t|
    t.string   "location"
    t.integer  "idea_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "events", ["idea_id"], name: "index_events_on_idea_id"

  create_table "ideas", force: true do |t|
    t.string   "title"
    t.text     "descrption"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

我看到了这一点。而且我不明白为什么它同时显示下拉选择想法和附加数字编辑框?

在此处输入图像描述.

4

1 回答 1

1

RailsAdmin严重依赖您的关系来动态生成表单。除此之外,如果您没有从两个模型映射您的关系,您可能会遇到其他问题。

class Idea < ActiveRecord::Base
  # missing
  has_many :events
end

class Event < ActiveRecord::Base
  belongs_to :idea
end
于 2013-08-28T19:44:43.973 回答