Throughout our site there's a common model, let's say Video, that has a number of attributes like private/public/pending, downloadable, etc.
Based on the controller, action, request parameters and current user, we want to filter out particular videos from display. For instance, on the homepage we only want to show videos that are public. If there is a logged in user on the homepage we also want to show public downloadable videos.
We also want to make sure that these filters can be applied through sql queries alone, so that using Sphinx we can filter out undesired videos when a user does a search on the site.
Is this best handled through an authorization plugin, such as rails-authorization-plugin? Bottom line our goal is to prevent programmers from accidentally forgetting to filter out particular videos when they add a new action. The solution we're looking for should be very programmatic.
Here's a solution I'm thinking of (haven't written any code yet)
Make use of an authroization plugin or roll our own that allows setting which videos are displayed, defined at the controller or action level.
Create an association extension for any model that has_many(:videos) or has_one(:video), which allows us to overload the finder for videos in the association.
Overload Video.find in a similar manner to restrict what to display based on the current rules.