title: Nested resource id mix-up in member_action
body: <p>I have an action_item on a SupportSession resource 'show' page. Note that this particular resource is nested under SupportAllocation:</p>
  
  <pre><code>ActiveAdmin.register SupportSession do
    belongs_to :support_allocation
  </code></pre>
  
  <p>Here's the action_item code for this nested SupportSession resource:</p>
  
  <pre><code>  action_item :request_approval, only: :show do
      link_to 'Send to service user', request_approval_support_allocation_support_session_path(resource), method: :patch
    end
  </code></pre>
  
  <p>And the corresponding member_action code:</p>
  
  <pre><code>  member_action :request_approval, method: :patch do
      # These commented lines all throw the same error described below
      #raise support_allocation.support_session
      #resource.status = "awaiting_approval"
      #resource.save
      #ServiceUserMailer.send_session_approval_request_email(resource).deliver_now
      redirect_to support_allocation_support_session_path, notice: "Session sent to service user for approval"
    end
  </code></pre>
  
  <p>The action_item button renders correctly on the 'show' page and successfully calls the member_action, however when this happens, it seems that the id of the nested resource (SupportSession id) and its parent (SupportAllocation) get mixed up, resulting in the following exception error:</p>
  
  <pre><code>ActiveRecord::RecordNotFound in SupportSessionsController#show
  Couldn't find SupportSession with 'id'=9 [WHERE `support_sessions`.`support_allocation_id` = ?]
  </code></pre>
  
  <p>Interestingly, in the browser address bar, the URL is now:</p>
  
  <pre><code>http://localhost:3000/support_allocations/9/support_sessions/9
  </code></pre>
  
  <p>This is reflected in the parameters shown on the exception caught:</p>
  
  <pre><code>Request
  Parameters:
  
  {"_method"=&gt;"patch", "authenticity_token"=&gt;"bZvr+kEThv/uri2E/zL/OWkndFmiQ+7FcGMD6fY3EQrh6d0vNqUaNvc0tC9BJliUYAyF4lxV+8/4T24YxQWzNg==", "support_allocation_id"=&gt;"9", "id"=&gt;"9"}
  </code></pre>
  
  <p>Which shows that the id of the support_session (9) has become mixed up with the support_allocation_id (which should be 6 in this particular case). Consequently the method/association won't work, because support_allocation_id = 9 doesn't exist in my database.</p>
  
  <p>If I run:</p>
  
  <pre><code>raise resource.inspect
  </code></pre>
  
  <p>in my action_item, the object appears correct before the member_action is called:</p>
  
  <pre><code>#&lt;SupportSession id: 9, venue: "Cafe", start_time: "2019-05-15 16:12:00", end_time: "2019-05-15 16:35:00", status: "unapproved", created_at: "2019-08-23 09:11:05", updated_at: "2019-08-23 09:11:05", support_allocation_id: 6&gt;
  </code></pre>
  
  <p>Any ideas why the member_action isn't getting the right data and throwing the error above? Is this something to do with it being a nested resource? </p>
  
  <p>For your information, this association between the SupportSession and SupportAllocation is reflected in my model:</p>
  
  <pre><code>class SupportAllocation &lt; ApplicationRecord
    has_many :support_sessions
  
  class SupportSession &lt; ApplicationRecord
    belongs_to :support_allocation
  </code></pre>
  
  <p>Here's the output from rails routes:</p>
  
  <pre><code>request_approval_support_allocation_support_session PATCH      /support_allocations/:support_allocation_id/support_sessions/:id/request_approval(.:format) support_sessions#request_approval
     batch_action_support_allocation_support_sessions POST       /support_allocations/:support_allocation_id/support_sessions/batch_action(.:format)         support_sessions#batch_action
                  support_allocation_support_sessions GET        /support_allocations/:support_allocation_id/support_sessions(.:format)                      support_sessions#index
                                                      POST       /support_allocations/:support_allocation_id/support_sessions(.:format)                      support_sessions#create
               new_support_allocation_support_session GET        /support_allocations/:support_allocation_id/support_sessions/new(.:format)                  support_sessions#new
              edit_support_allocation_support_session GET        /support_allocations/:support_allocation_id/support_sessions/:id/edit(.:format)             support_sessions#edit
                   support_allocation_support_session GET        /support_allocations/:support_allocation_id/support_sessions/:id(.:format)                  support_sessions#show
                                                      PATCH      /support_allocations/:support_allocation_id/support_sessions/:id(.:format)                  support_sessions#update
                                                      PUT        /support_allocations/:support_allocation_id/support_sessions/:id(.:format)                  support_sessions#update
                                                      DELETE     /support_allocations/:support_allocation_id/support_sessions/:id(.:format)                  support_sessions#destroy
  </code></pre>