![](/img/trans.png)
[英]Ruby on Rails: How to do a query on a table having two foreign key references with ActiveRecord
[英]Rails ActiveRecord How to make foreign key in second table?
一個簡單的問題:如何使“ rateable_id”成為bboys表的外鍵?
數據庫模式:
ActiveRecord::Schema.define(version: 20140331112614) do
create_table "bboys", force: true do |t|
t.string "name"
t.string "crew"
t.string "country"
t.datetime "created_at"
t.datetime "updated_at"
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
end
create_table "rates", force: true do |t|
t.integer "rater_id"
t.integer "rateable_id"
t.string "rateable_type"
t.float "stars", null: false
t.string "dimension"
t.datetime "created_at"
t.datetime "updated_at"
end
謝謝!
檢查寶石外國人 ,它可能會幫助您。 我不知道你到底想要什么 嘗試編寫有關您問題的更多描述。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.