【发布时间】:2014-08-10 16:19:45
【问题描述】:
型号:
class User < ActiveRecord::Base
has_many :reports
has_many :social_accounts
has_one :api_client
has_many :integrations
has_many :profiles, through: :integrations
has_many :tags
has_many :profiles, through: :tags
end
class Tag < ActiveRecord::Base
belongs_to :user
belongs_to :profile
end
class Profile < ActiveRecord::Base
has_many :integration_profiles
has_many :integrations, through: :integration_profiles
has_many :users, through: :integrations
belongs_to :api_client
has_many :tags
ene
有时我想通过集成检索所有用户的个人资料,有时通过标签检索。如何?
【问题讨论】:
标签: ruby-on-rails has-many-through