I see what you're saying, but I think it's a little presumptuous to
dictate this architecture just to satisfy an abstract concept of how
things should be structured.  David often says how he hates contrived
examples, and removing with_scope access to other models feels like
it's based on certain assumptions that don't always hold.   Here's
why:

* The first thing is that ideally this would be modelled by User
has_many :accessible_properties, but that is not possible because
accessible_properties does not have static conditions (they depend on
the instance, therefore they can't hardcoded with a class macro... if
there is a way around this please do tell).  An association proxies to
another model without requiring extra hooks to be defined on the
target model.  I want to do the exact same thing because:
* The notion of accessible properties is mostly meaningful to the
user.  I think if you saw my entire app, you would see my point of
view.  I have a pretty clean division of concerns where the User model
is in charge of policing its own access to things, while the other
models just remain focused on their own data.  I realize this is sort
of a 6-of-one-half-a-dozen-of-the-other aesthetic issue, but:
* If I decide the only meaningful interface is through User, why
should I have to have twice the methods and add a layer of indirection
where with_scope is specifically designed for this situation?  Rails
does place high value on aesthetics after all.

In short, I'm not trying to make a nuisance of myself on an old issue.
 When I heard with_scope would be protected it didn't bother me
because I just assumed it would work in all models, but I didn't
realize it would mean you could only scope within the same model.
Given the limitations of associations, I think that's an undue
restriction.

On 6/18/07, Tim Lucas <[EMAIL PROTECTED]> wrote:
>
> On 19/06/2007, at 11:47 AM, dasil003 wrote:
>
> > * I know I could work around this by refactoring the functionality
> > into Property and passing the user as a parameter, but that makes my
> > code both more complicated and more opaque.  The User should know what
> > properties it can access.  A Property shouldn't have any concept of
> > the user.
>
> The Property store should be the one responsible for scoping its own
> data retrieval. If the User needs to specify conditions then it
> shouldn't be done w/o the Property datastore's knowledge
> (with_scope), it should tell the Property data store the conditions
> it wants applied, and the Property store can use whatever it needs to
> make that happen (in this case an AR with_scope). See Rick's example
> for a better separation of responsibilities.
>
> -- tim
>
>
> >
>


-- 
Gabe da Silveira
http://darwinweb.net

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to