Alright Marnen, I think I'm getting it... I was able to get the team members by using the following in the projects controller:
@teammembers = @project.users That gives me the users, but it doesn't provide the user's roles. I tried including/joining roles to the code above but that errored. Any tips? On Sep 17, 3:27 pm, nobosh <[email protected]> wrote: > Thanks Marnen, obviously it hasn't clicked yet but I'll get it! Am I > at least right trying to get this to work as a Scope in the Project's > model, so I can have the controller pass the team members array to the > Controller to the view projects> show.html.erb? > > Thanks > > On Sep 17, 3:22 pm, Marnen Laibow-Koser <[email protected]> wrote: > > > > > nobosh wrote: > > > Continuing along this thread... 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 > > > You're making the exact same mistake as before. Project.permissions > > just returns an array of Permission objects. > > > Best, > > -- > > Marnen Laibow-Koserhttp://www.marnen.org > > [email protected] > > > Sent from my iPhone > > -- > > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

