दाएं। यह बस काम करने से इंकार कर देता है। घंटों के लिए इस पर किया गया।रेल 4 एसोसिएशन नहीं मिला है, के माध्यम से: रिश्ते त्रुटि
एलबम मॉडल
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
परीक्षण डेटाबेस बटोर, और चल रहा है इस एकीकरण परीक्षण पर:
012,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
ऐसा क्यों है मिल सकता है?
मुझे नहीं लगता कि संबंध तालिका के नामकरण सम्मेलन में हैसनी के साथ संबंध है। – Starkers
आपके पास नाम फ़ीचर के साथ 2 मॉडल नहीं हो सकते हैं, यही मायने रखता है। – biomancer
इसके अलावा, एक सक्रियरेकॉर्ड मॉडल का नाम इसके तालिका के नाम से मेल खाना चाहिए। – biomancer