Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9158385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:14:01+00:00 2026-06-17T13:14:01+00:00

I have a nested route, appointments and schedules when I try to go to

  • 0

I have a nested route, appointments and schedules
when I try to go to doctors/1/appointments/ or doctors/1/schedules/ I get a route error. to me it looks like theres an error with the links inside the index page but I checked rake routes and everything seems to be fine. the edit, show and new actions works fine.

What am I doing wrong?

route.rb

Pgranges::Application.routes.draw do

  root :to => "Doctors#index"

  resources :doctors do
    resources :appointments  
    resources :schedules  
  end

  resources :appointment_steps
end

this is my index file:

<h1>Listing appointments</h1>

<table>
  <tr>
    <th>Doctor</th>
    <th>Adate</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @appointments.each do |appointment| %>
  <tr>
    <td><%= appointment.doctor_id %></td>
    <td><%= appointment.adate %></td>
    <td><%= link_to 'Show', doctor_appointment_path %></td>
    <td><%= link_to 'Edit', edit_doctor_appointment_path(appointment) %></td>
    <td><%= link_to 'Destroy', doctor_appointment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New Appointment', new_doctor_appointment_path %>

and my controller look like this:

class SchedulesController < ApplicationController
  def index
    @doctor = Doctor.find(params[:doctor_id])    
    @schedules = @doctor.schedules.all



    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @schedules }
    end
  end

  def show
    @doctor = Doctor.find(params[:doctor_id])        
    @schedule = @doctor.schedules.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @schedule }
    end
  end

  def new
    @doctor = Doctor.find(params[:doctor_id])
    @schedule = @doctor.schedules.new

    @doctors = Doctor.all


    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @schedule }
    end
  end

  def edit
    @doctor = Doctor.find(params[:doctor_id])    
    @schedule = @doctor.schedules.find(params[:id])
  end

  def create
    @doctor = Doctor.find(params[:doctor_id])    
    @schedule = @doctor.schedules.new(params[:schedule])

    if @schedule.save
      redirect_to doctor_url(@schedule.doctor_id)
    else
      render action: 'new'
    end


  end

  def update
    @schedule = Schedule.find(params[:id])

    respond_to do |format|
      if @schedule.update_attributes(params[:schedule])
        format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @schedule.errors, status: :unprocessable_entity }
      end
    end
  end

  def destroy
    @schedule = Schedule.find(params[:id])
    @schedule.destroy

    respond_to do |format|
      format.html { redirect_to schedules_url }
      format.json { head :no_content }
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:14:02+00:00Added an answer on June 17, 2026 at 1:14 pm

    You should pass both resources (doctor and appointment) to route helpers for nested resources. Also, your forgot _path for delete link. Try this:

    <td><%= link_to 'Show', doctor_appointment_path(appointment.doctor, appointment) %></td>
    <td><%= link_to 'Edit', edit_doctor_appointment_path(appointment.doctor, appointment) %></td>
    <td><%= link_to 'Destroy', doctor_appointment_path(appointment.doctor, appointment), method: :delete, data: { confirm: 'Are you sure?' } %></td>
    

    UPDATE:

    Also, for new appointment link:

    <%= link_to 'New Appointment', new_doctor_appointment_path(appointment.doctor) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok guys so I have a nested route like this: resources :apps do resources
I have a nested route like so: resources :apps do resources :issues end the
I have a nested route as: resources :wsps do member do get :location get
I have a pretty common case for nested routes, I feel like, that looks
I am attempting to get rails routes paths via nested resources. I have looked
I have nested iframes and I would like to use onload function for the
I'm using Rails 2. I have resources nested like this: - university_categories - universities
I have a resourceful route, with a post route nested within it: resources :groups,
I have gone through tons of the form_for nested resource questions and can't get
I have a nested route: resources :period_registrations do member do post :save_period end that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.