Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do ARel scopes become read-only when using joins?

Tags:

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?