title: Nested resources Rails no route matches id = nil
body: <p>I'm dealing with nested routes and I felt something is missing, I get this error:</p>
  
  <pre><code>No route matches {:action=&gt;"edit", :controller=&gt;"consultations", :id=&gt;nil, :patient_id=&gt;#&lt;Patient id: 2 ...
  </code></pre>
  
  <p><strong>Routes:</strong></p>
  
  <pre><code>resources :patients, shallow: true do
      resources :consultations
  end
  </code></pre>
  
  <p><strong>rake routes | grep consultation</strong></p>
  
  <pre><code>patient_consultations GET /patients/:patient_id/consultations(.:format) consultations#index
  POST /patients/:patient_id/consultations(.:format) consultations#create
  new_patient_consultation GET /patients/:patient_id/consultations/new(.:format) consultations#new
  edit_consultation GET /consultations/:id/edit(.:format) consultations#edit
  consultation GET /consultations/:id(.:format) consultations#show
  PATCH  /consultations/:id(.:format)  consultations#update
  PUT    /consultations/:id(.:format)  consultations#update
  DELETE /consultations/:id(.:format)  consultations#destroy
  </code></pre>
  
  <p><strong>Models:</strong></p>
  
  <pre><code>class Patient &lt; ActiveRecord::Base
    belongs_to :medic, :foreign_key =&gt; :medic_id
    has_many :consultations, :dependent =&gt; :destroy
    accepts_nested_attributes_for :consultations
  end
  
  class Consultation &lt; ActiveRecord::Base
    belongs_to :patient, :foreign_key =&gt; :patient_id
  end
  </code></pre>
  
  <p><strong>View:</strong> <em>consultations/index.html.erb</em></p>
  
  <pre><code>&lt;% @patient.consultations.each do |consultation| %&gt;
    &lt;%= link_to 'Edit', edit_consultation_path(patient_id: @patient, id: @consultation) %&gt; &lt;---ERROR
    &lt;%= link_to 'Show', consultation(patient_id: @patient, id: @consultation) %&gt; &lt;---ERROR
    &lt;%= link_to 'Destroy', consultation, method: :delete, data: { confirm: 'Are you sure?' } %&gt; &lt;---ERROR
  &lt;% end %&gt;
  </code></pre>
  
  <p>Am I passing wrong parameters to <strong>edit_consultation_path(patient_id: @patient, id: @consultation)</strong> ?</p>
  
  <p>Any ideas? thanks in advance!</p>
  
  <p><strong>edit:</strong></p>
  
  <p><strong>Controller:</strong> controller/consultations_controller.rb</p>
  
  <pre><code>def index
    @patient.consultations = Consultation.all
  end
  </code></pre>