If you use joins
in an ARel scope, the result becomes read-only (i.e. you cannot update any of the records you get back). If you would not like the result to be read-only, you just chain readonly(false)
to the scope, e.g.
User.joins(:orders).where(:orders => { :state => 'completed' }).readonly(false)
But I'm guessing that there is a reason why the join-scopes by default are read-only. What is the reason behind setting the results to read-only?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With