के माध्यम से मैं किस हद तक मैं रेल में संघों का उपयोग कर सकते करने के लिए सोच रहा हूँ।रेल has_many: has_many के माध्यम से:
class User < ActiveRecord::Base
has_one :provider
has_many :businesses, :through => :provider
end
class Provider < ActiveRecord::Base
has_many :businesses
has_many :bids, :through => :businesses
belongs_to :user
end
class Business < ActiveRecord::Base
has_many :bids
belongs_to :provider
end
class Bid < ActiveRecord::Base
belongs_to :business
end
मैं User.bids
की तरह कुछ करने के बारे में User.businesses
और Provider.bids
की तरह इन गंधा शॉर्टकट लेकिन क्या स्थापित करने के लिए कर रहा हूँ: ध्यान में निम्नलिखित ले लो? क्या एक एसोसिएशन को जोड़ना संभव है, तो बोलने के लिए?
यह संभव है, लेकिन क्योंकि आप नीचे अपने डेटाबेस दलदल और एप्लिकेशन रेल कर सकते हैं, के बारे में कितनी गहराई तक आप घोंसला सावधान रहने की जरूरत है। ऐसा कहा जा रहा है कि, मैंने एक ब्लॉग पोस्ट लिखा है जो विवरण करने के लिए nested_has_many_through का उपयोग कैसे करता है: http://kconrails.com/2010/01/28/nesting-has_many-through-relationships-in-ruby-on-rails/ –