Idea for a Rails linting rule: every AR find must either be in a conditional or be a bang Either: widget = Widget.find_by! color: "green" Or if(widget = Widget.find_by color: "green") # ... There's no reason to ever leave the discovery of a nil for later. Is there?
-
Show this thread
Replying to @avdi
You might find a design choice I made in Diesel interesting. Method which return 1 record treat no record as an error by default, with an extension on `Result<T, DieselError>` to convert to `Result<Option<T>, DieselError>` turning `NotFound` into `None`
3:10 PM - 5 Dec 2019
0 replies
0 retweets
6 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.