对.这只是拒绝工作.在这几个小时.
专辑模特儿
class Album < ActiveRecord::Base has_many :features,through: :join_table1 end
特征模型
class Feature < ActiveRecord::Base has_many :albums,through: :join_table1 end
join_table1模型
class JoinTable1 < ActiveRecord::Base belongs_to :features belongs_to :albums end
join_table1模式
album_id | feature_id
专辑模式
id | title | release_date | genre | artist_id | created_at | updated_at | price | image_path
功能模式
id | feature | created_at | updated_at
在碾压测试数据库并运行此集成测试:
require 'test_helper' class DataFlowTest < ActionDispatch::IntegrationTest test "create new user" do album = albums(:one) feature = features(:one) album.features end end
我得到
ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :join_table1 in model Album
为什么是这样?