Hacker News new | past | comments | ask | show | jobs | submit login

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...




Finally! 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: