user.role_for_project(project) seems to be working nicely. Hopefully that's the right Rails way to do it.
On Sep 15, 4:47 pm, Marnen Laibow-Koser <[email protected]> wrote: > nobosh wrote: > > Better way to phrase the question... Given the model above, > > > Knowing the project_id and user_id, how in Rails using activemodel can > > you query to obtain the user's role if any,,, meaning return admin or > > nil > > > I'm trying things like in the users.rb: > > logger.debug self.permissions.find_by_project_id(1) > > > But that doesn't give back a role... > > Of course it doesn't. You asked it for a Permission object, and that's > what you're getting. You want the Role that that Permission belongs to. > So...can you figure it out now? > > > Tricky stuff!!! > > No, actually, this is very simple. If you find it tricky, you need to > think more clearly about the structure of your associations and queries. > > 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.

