0
我必須處理這個錯誤,當我嘗試將記錄通過HABTM關聯另一個相關聯:「類型錯誤:的零到字符串的隱式轉換」上HABTM協會
Person.first.communities = Communities.all
模型和遷移:
class CreatePeople < ActiveRecord::Migration
def change
create_table :people do |t|
t.string :name
t.string :email
t.timestamps null: false
end
end
end
class CreateCommunities < ActiveRecord::Migration
def change
create_table :communities do |t|
t.string :name
t.text :description
t.timestamps null: false
end
end
end
class CreateJoinTablePersonCommunity < ActiveRecord::Migration
def change
create_join_table :people, :communities do |t|
# t.index [:person_id, :community_id]
# t.index [:community_id, :person_id]
end
end
end
我使用pg (0.18.4)
寶石與下面的代碼Postgres (9.5.2)
您是否也可以顯示相關聯繫的模型? – smefju