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
-~----------~----~----~----~------~----~------~--~---

Reply via email to