【发布时间】:2020-11-22 20:44:25
【问题描述】:
一个真正的菜鸟问题,但我尝试了不同的选项,但我不明白。
我有一个新的“Cancha”表单和一个引用“Mmpp”的字段,在 mmpp_id 字段中我需要查看一个包含不同类型“Mmpp”的列表(已经创建了一些选项),现在如果我输入例如“1”,我在节目中得到 Mmpp:0x00007f7fb1600378,已经将节目更改为 我得到了我想要的节目,但问题出在表格我需要一个列表来选择。 提前致谢
<%= form.text_field :mmpp_id, class: 'form-control' %>
create_table "canchas", force: :cascade do |t|
t.string "nombre"
t.string "descripcion"
t.integer "capacidad"
t.boolean "operativa"
t.bigint "mmpp_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["mmpp_id"], name: "index_canchas_on_mmpp_id"
create_table "mmpps", force: :cascade do |t|
t.string "nombre"
t.string "descripcion"
t.integer "densidad"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
【问题讨论】:
-
为此使用
select_tag,您可以从 mmpps 表中的所有记录中选择 id 和 name。您可能还想将列重命名为英文。
标签: ruby-on-rails ruby postgresql activerecord simple-form