Given the following:
class User < AR::B
has_many :permissions
has_many :projects, :through => :permissions
end
class Project < AR::B
has_many :permissions
has_many :users, :through => :permissions
end
class Role < AR::B
has_many :permissions
end
class Permission < AR::B
belongs_to :user
belongs_to :project
belongs_to :role
end
I'm interested in creating a SCOPE in the project model (project.rb) that returns all the project's members (bassed on the permissions table <> users & role tables.
Desired output: user.name, role.name
Here's my scope in the model, which isn't returning the desired output:
class Project < ActiveRecord::Base
has_many :permissions
has_many :users, :through => :permissions
#Playing with Scopes
scope :teammembers,
Project.permissions.joins(:users, :roles)
end
trying to figure out how to get the output with ActiveRecord. Thanks