【发布时间】:2017-10-11 09:14:12
【问题描述】:
我有两个表,accounts 和 items,我想在 view/items/show.html.erb 页面上的帐户表中使用 show buisness_name 而不是 id。
目前我没有模型之间的关联,但我在items 表中有account_id 列。
create_table "accounts", force: :cascade do |t|
t.string "buisness_name"
t.string "web_site"
t.string "phone_number"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "items", force: :cascade do |t|
t.string "title"
t.text "description"
t.string "image"
t.decimal "price"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "category_id"
t.json "attachments"
t.integer "account_id"
end
我通过这个<%= @item.account_id %> 获得account_id,但我想改为显示buisness_name。
【问题讨论】:
-
JFYI,这是“商业”,而不是“商业”
-
“目前我没有模型之间的关联” - 这就是你需要解决的问题。
标签: ruby-on-rails ruby ruby-on-rails-4