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