0
用戶屬於組織,而組織又可以有多個用戶和子組織。你如何找到所有的組織用戶?查找組織中的所有用戶,它是子組織
我有名爲User
和Organization
的型號。它們具有以下關係:
在用戶模式:
belongs_to :organization
在組織模式:
has_many :users
has_many :child_organizations, class_name: "Organization", foreign_key:"parent_id"
belongs_to :parent, class_name: "Organization"
我想找個誰屬的child_organizations
所有用戶當前用戶組織。
@users = current_user.organization.child_organizations.users
它返回此錯誤:根據您的問題的格式
undefined method `users' for Organization::ActiveRecord_Associations_CollectionProxy:0x8f975d0
您應該編輯您的問題並按照型號 – Prasad