Thanks for the quick response!
You're asking two different questions actually :
> Is there a way to specify at the model level that you want all
> find(), find_by_xxxx(), etc, to include a certain :conditions
The plugin ScopedAccess
does just that. You may look at the code to see how it works.
ok that looks cool - but according to a comment at the bottom of that
page "This has been incorporated into Rails" - is that true? The
homepage for it gives a 404 and there seems to be some red flags about
it in other posts... hmm. Another scary plugin?
[another topic: Is there anything in Rails equivalent to CPAN or PEAR
where you can reasonably be sure the code is stable and high-quality?
I've already gone down the road with a few plugins that were broken or
deprecated or at least early beta]
> for instance, if normally you wanted to only select articles
> where "is_published = 1"
That's a different case, and much easier to satisfy thanks to Rails
class User << AR
has_many :published_articles , :conditions => "is_published
= 1" ,
:class_name => 'Article', :foreign_key
ok I was aware of this option but how would I over-ride it if the
current user was an admin for instance? Do I have to create a separate
association for every combination of flags then, and call different
methods based on the role of the current_user? (say I have
is_published, is_deleted, is_public_domain - that's 9 potential