I think nested routes are quite cool and useful, specially if instead of using numerical IDS you use codes that have a meaning for the user
so projects/2/tasks_category/3/task/5 becomes projects/CoolWebApp/task_categories/design/tasks/user_profile Such a url is hackable and meaningful, it's currently supported by rails and I'd be disappointed if it won't anymore. that's my 0.02 Paolo On 03/08/07, Michael Glaesemann <[EMAIL PROTECTED]> wrote: > > > On Aug 3, 2007, at 17:01 , Brian Hogan wrote: > > > Well see that's exactly why I am confused. > > I understand the data integrity thing and the security thing, but > > how far do you take that? > > > > /users/1/projects/2/tasks/3/notes/4 > > > > @user.find(params[:user_id] > > @project @user.projects.find(params[:project_id] > > @task = @project.tasks.find(params[:task_id] > > @note = @task.notes.find(params[:id] > > > > That just really seems to get messy. Is that really the approach > > you'd take? I assume you'd use some sort of includes there to > > reduce the db calls then, right? > > > > AIUI, In this situation, I'd be in the notes_controller. I'd have > already set up find_user, find_project, find_task, and > find_note_by_id methods called by before_filter, e.g., > > # in application.rb > private > def find_user > @user = User.find(params[:user_id]) > end > > def find_project > @project = @user.projects.find(params[:project_id]) > end > > def find_task > @task = @project.tasks.find(params[:task_id]) > end > > # in notes_controller.rb > private > before_filter :find_user > before_filter :find_project > before_filter :find_task > before_filter :find_note, :except => [:index, :new, :create] > > def find_note_by_id > @note = @task.notes.find(params[:id]) > end > > Very succinct, I believe. > > Michael Glaesemann > grzm seespotcode 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 -~----------~----~----~----~------~----~------~--~---
