4 ms·
Rails 7 has finally added this to active record: sole and find_sole_by Both raise an exception unless a single record is found. Of course this would not make
by house9-2 5y ago
Rails 7 has finally added this to active record: sole and find_sole_by
Both raise an exception unless a single record is found.
Of course this would not make a difference when working with mongoid... I also like the fail fast approach.
https://blog.saeloun.com/2021/03/16/rails-adds-sole-and-find-sole-by.html https://blog.saeloun.com/2021/03/16/rails-adds-sole-and-find...
- jbverschoor 5y agoFinally! I don't like the name though. but I'll live with it. Well, at least they added it to Enumerable, so you could use it with mongoid.