【发布时间】:2013-09-29 11:50:46
【问题描述】:
没错。这只是拒绝工作。在这里呆了几个小时。
专辑模型
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:在模型相册中找不到关联:join_table1
这是为什么?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 has-many-through