This project is archived and is in readonly mode.
ActiveRecord::Base.joins no longer accepts nil
Reported by Matthew Ratzloff | December 16th, 2010 @ 07:02 PM
A break with previous functionality was introduced with Aaron Patterson's recent change to joins, found here:
https://github.com/rails/rails/commit/d98cb5153dad97cde82ec91a1993043cfa9bc0e4
ActiveRecord's joins method no longer accepts either nil or [nil], which breaks some applications that depended on that. Specifically, CanCan's ActiveRecord::Base.accessible_by method now breaks if there are no joins.
https://github.com/ryanb/cancan/blob/master/lib/cancan/active_record_additions.rb
ActiveRecord where(nil), on the other hand, returns a result.
Comments and changes to this ticket
-
Matthew Ratzloff December 16th, 2010 @ 08:38 PM
So basically, you just need to call Array#compact on it before handling it in ActiveRecord::QueryMethods.joins. This fixes the issue.
I've attached a monkey patch for others having trouble.
-
Repository December 16th, 2010 @ 09:27 PM
- State changed from new to resolved
(from [40b15f9f389b9394b22cf36567269e54c66c9fc8]) ActiveRecord::Base.joins should allow single nil argument [#6181 state:resolved] https://github.com/rails/rails/commit/40b15f9f389b9394b22cf36567269...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 6181 ActiveRecord::Base.joins no longer accepts nil (from [40b15f9f389b9394b22cf36567269e54c66c9fc8]) ActiveR...