title: Rails parameter passing issue despite console showing parameter correctly passed and controller correctly called
body: <p>I am struggling on a <strong>simple parameter passing issue</strong> around simplified code for debugging purpose. I want to pass an apartment object to change one of its boolean attribute (show_email) from true to false using a custom controller</p>
  <p>Here is the link in my view calling the hide_contact_email action in the apartment controller</p>
  <pre><code> &lt;%= link_to &quot;Hide temporarily&quot;, apartment_hide_contact_email_path(apartment), method: :put %&gt;
  </code></pre>
  <p>Here is the simplified controller apartments_controller.rb where I just want to see the passed apartment_id</p>
  <pre><code>def hide_contact_email
    #I want to check what I get in the console
    puts apartment_id
    redirect_to landlord_dashboard_path
  end
  </code></pre>
  <p>The console give me an <strong>undefined variable error</strong>.</p>
  <pre><code>Started PUT &quot;/apartments/61/hide_contact_email&quot; for 127.0.0.1 at 2021-09-10 10:35:11 +0800
          Processing by ApartmentsController#hide_contact_email as HTML
            Parameters: {&quot;authenticity_token&quot;=&gt;&quot;acsMqJMWR6rM9ooAzmhXKEJVP1HimENQpSMt1SrP3jZBWFxktNk5BI1rhu8BjN8zAdk93+0ksLTa63/YgOnyTQ==&quot;, &quot;apartment_id&quot;=&gt;&quot;61&quot;}
          Completed 500 Internal Server Error in 2141ms (ActiveRecord: 0.0ms | Allocations: 185548)
          NameError (undefined local variable or method `apartment_id' for #&lt;ApartmentsController:0x000055acd9351868&gt;
          Did you mean?  apartment_url):  
          app/controllers/apartments_controller.rb:54:in `hide_contact_email'
  </code></pre>
  <p>I am confused how come I get an undefined local variable apartment_id where the console clearly states that 1) the right controller is called (<strong>Processing by ApartmentsController#hide_contact_email</strong>) and 2) the parameter has been passed (<strong>apartment_id =&gt;&quot;61&quot;</strong>). Thank you.</p>