2009/3/6 Pesho Petrov <[email protected]>

>
> Colin Law wrote:
>
> > Yes.  The question is, of course, has any of this helped with your
> > original
> > question? I think it has as you can now find all messages where the
> > membership.role_id is admin and membership.member_id is the member you
> > want
>
> yes, we are back to the first question :)
> you are right. This is the logic, but how do I express it in Rails
> syntax??
> (I think) I cannot use Message.find, because the Message model doesn't
> have info about roles...
>

Yes it does, the relationships give it that information.  If you have a
message then you can say a_message.membership.role. You can also do
something like
Message.find(:all, :include => :membership, :conditions =>
['membership.role_id =?', a_role_id])
I am not guaranteeing the exact syntax, I may have made a silly mistake as I
have not done much yet myself.  Possibly a bit of a case of the blind
leading the blind.  Play about a bit and look in development.log to see the
actual sql if it is not working for you.


>
> Best,
> Petar
> --
> Posted via http://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to