title: nested resources with form_for losing first id
body: <p>This is a strange error that has really got me bugged. First, some background.</p>
  
  <p>I have the following nested resources in my config/routes.rb:</p>
  
  <pre><code>scope :requirements =&gt; { :protocol =&gt; 'https' } do
      resource :user
      resources :orgs do
          resources :members
          resources :events
          resources :levels
          resources :attendances
      end
      resources :sessions,    :only =&gt; [:new, :create, :destroy]
  end
  </code></pre>
  
  <p>Then, in app/controllers/levels_controller.rb I have:</p>
  
  <pre><code>def edit
      @org = Org.find(params[:org_id])
      @level = OrgLevel.find(params[:id])
  end
  
  def update
      @level = OrgLevel.find(params[:id])
      if @level.update_attributes(params[:level])
          flash[:success] = "Level details updated"
          redirect_to @level
      else
          render 'edit'
      end
  end
  </code></pre>
  
  <p>Finally, in app/views/levels/edit.html.erb, I have:</p>
  
  <pre><code>&lt;% provide(:title, "Edit #{@level.name} for #{@org.name}") %&gt; 
  &lt;div class="hero-unit"&gt;
      &lt;h2&gt;Edit &amp;quot;&lt;%= @level.name %&gt;&amp;quot; membership level for &lt;%= @org.name %&gt;&lt;/h2&gt;
      &lt;div class="row"&gt;
          &lt;div class="span6 offset3"&gt;
              &lt;%= form_for [@org, @level], :url =&gt; org_level_path do |f| %&gt;
                  &lt;%= render 'shared/error_messages' %&gt;
                  &lt;table class="editor"&gt;
                      &lt;tr&gt;
                          &lt;td class="label_x"&gt;
                              &lt;%= f.label :name %&gt;
                          &lt;/td&gt;
                          &lt;td colspan="3"&gt;
                              &lt;%= f.text_field :name %&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;% end %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The result of calling <a href="https://spot-macbook.local/orgs/55/levels/162/edit" rel="nofollow">https://spot-macbook.local/orgs/55/levels/162/edit</a> is normal, but clicking "Save Changes" results in a redirection to <a href="https://spot-macbook.local/orgs/162/levels/162" rel="nofollow">https://spot-macbook.local/orgs/162/levels/162</a> and the following error:</p>
  
  <pre><code>ActiveRecord::RecordNotFound in LevelsController#show
  
  Couldn't find Org with id=162
  Rails.root: /Users/ogod/Projects/rails_projects/nom_de_joye_app
  
  Application Trace | Framework Trace | Full Trace
  app/controllers/levels_controller.rb:71:in `correct_user'
  Request
  
  Parameters:
  
  {"requirements"=&gt;{"protocol"=&gt;"https"},
   "org_id"=&gt;"162",
   "id"=&gt;"162"}
  </code></pre>
  
  <p>Note that the org_id has changed to "162" instead of "55". What am I doing wrong?</p>