显示名称,而不是标识我有两个表,accounts
和items
,我想从账目表show
的buisness_name
代替id
的view/items/show.html.erb
页面上。的Rails:在节目页
目前我没有模型之间的关联,但我有表中的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
我得到通过这个account_id
:<%= @item.account_id %>
,但我想,以显示buisness_name
代替。
JFYI,这是“业务”,而不是“ buisness“ –
”目前我的模型之间没有关联“ - 这就是你需要解决的问题。 –