Those filters are easily memcached when you start hitting loads, and are easily stubbed in your controller spec. You can also combine some of those calls with an :include.
Also, some of the actual find_xx methods belong in application controller. ------- Courtenay On Aug 3, 2007, at 6:30 PM, "Brian Hogan" <[EMAIL PROTECTED]> wrote: > ha! Of course. That makes total sense. :) Wow. Sometimes it's right > there in front of you. Thanks a lot! > > On 8/3/07, Tim Lucas < [EMAIL PROTECTED]> wrote: > > On 04/08/2007, at 8:39 AM, Brian Hogan wrote: > > > Indeed. I'd love to see examples of this proxy for authentication > > for teams of which he speaks. :) > > /projects/3/tasks/8/notes/2 > > class User < ActiveRecord::Base > has_many :roles > has_many :projects, :through => :roles > end > > class Project < ActiveRecord::Base > has_many :tasks > end > > class Task < ActiveRecord::Base > has_many :notes > end > > class NotesController < ApplicationController > before_filter :find_project > before_filter :find_task > before_filter :find_note > > def show > end > > protected > def find_project > @project = current_user.projects.find(params[:project_id]) > end > def find_task > @task = @project.tasks.find(params[:task_id]) > end > def find_note > @note = @task.notes.find(params[:id]) > end > end > > Notice each find is scoped using it's AR associations proxy, starting > from current_user.projects > > -- tim > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
