0
我有两个模型在Rails 5.1加入表错误上运行迁移
class Category < ActiveRecord::Base
has_and_belongs_to_many :sub_categories, join_table: "categories_join_table"
end
class SubCategory < ActiveRecord::Base
has_and_belongs_to_many :categories, join_table: "categories_join_table"
end
我已经加入多次迁移的问题是,当我尝试运行迁移我的错误ERROR: relation "comfort_factor_sub_categories" does not exist
因为在移民创建表comfort_factor_sub_categories将在稍后的迁移中运行。我该如何处理? 注意:我无法更改join_table的名称,因为它只是我长名的示例。
你有没有做什么,从什么在引导有关,建议有什么不同? http://guides.rubyonrails.org/association_basics.html#creating-join-tables-for-has-and-belongs-to-many-associations能让你分享你在迁移中所做的一切吗? – mabe02