Sorry -

That should have been, Message.public, not messages.public.
named_scope adds a class method

On Jun 21, 9:55 am, Gavin <[email protected]> wrote:
> Hi,
>
> why not add a named scope to messages:
>
> named_scope :public, :conditions => {:public => true}
>
> So you can call either:
> user.messages
> messages.public
> or
> user.messages.public
>
> Is that what you're looking for?
>
> Also, I think the standard for join tables is to name them in
> alphabetical order, so messages_users.
>
> Gavin
>
> On Jun 21, 7:05 am, Alexander Trauzzi <rails-mailing-l...@andreas-
>
> s.net> wrote:
> > Hello all!
>
> > I'm looking to get some help answering a design problem I'm facing.  I'm
> > definitely familiar with how models house all the business logic, but
> > when it RoR, I'm somewhat confused :)
>
> > If I have Users, and they have a HABTM relationship to Messages:
>
> > Users
> > o ID
> > o Name
>
> > Messages
> > o ID
> > o Body
> > o Public
>
> > Users_Messages
> > o User_ID
> > o Message_ID
>
> > What is the best practice to check two criteria for a kind of
> > authorization check?
> > The first being simply evaluating the HABTM relationship using
> > user.messages.
> > The second being that a user can see all messages where Public==true?
>
> > Both are separate, yet I want to be able to generate one list from these
> > two separate criteria in one call, mixing the results.
>
> > Hopefully I'm clear enough, thanks in advance for any help!
> > --
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to