Rails activerecord joins update_all attribute of joined table
<p>I have the following relations:</p>

<p>reservation.rb</p>

<pre><code>has_many :room_requests, dependent: :destroy, inverse_of: :reservation
accepts_nested_attributes_for :room_requests, allow_destroy: true
has_many :rooms, through: :room_requests
</code></pre>

<p>room_request.rb</p>

<pre><code>belongs_to :reservation
belongs_to :room
</code></pre>

<p>room.rb</p>

<pre><code>has_many :room_requests
has_many :reservations, through: :room_requests
</code></pre>

<p>And I'm trying update the attribute 'status' from rooms that belong to certain reservations. Something like:</p>

<pre><code>Reservation.joins(:rooms).update_all('rooms.status': 'to_clean')
</code></pre>

<p>But evidently it doesn't work like this. I want to do it in a single query  but I can't quite grasp it. What am I missing?</p>