Skip to content

Instantly share code, notes, and snippets.

@NIA
Last active December 11, 2015 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NIA/4605018 to your computer and use it in GitHub Desktop.
Save NIA/4605018 to your computer and use it in GitHub Desktop.
resources :doctors do
get 'new_schedule', :on => :member
end
resources :schedules do
get 'new_appointment', :on => :member
end
resources :appointments
# With this /doctors/123/new_schedule will map to DoctorsController#new_schedule
# and /schedules/321/new_appointment will map to SchedulesController#new_appointment
# And all other normal routes (show, edit, delete) will be simple in form :controller/:id/:action:
#
# doctors/123/show to show doctor with id 123
# schedules/321/edit to edit schedule with id 321 (we dont't need the ID of doctor to find it, so why nesting?)
# appointments/444/delete to delete appointment with id 444
#
# If you still want to show to user the fact of nesting this, you can show this on your page, like when you
# visit appointment 444, you can show something like...
# Doctor <name> > Schedule <title> > Apppointment <title>
# ... in your page
@jmercedes
Copy link

we are parsing doctor through schedule?

@NIA
Copy link
Author

NIA commented Jan 23, 2013

No, in this case from the point of routes all three resourses are independent and only need one parameter for URL generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment