rails-style-guide
rails-style-guide copied to clipboard
Add find-by-memoization section
To avoid a common pitfall, I propose to add a new section about @model ||= Model.find_by(...).
Actually, this was created based on the following cop discussion:
- https://github.com/rubocop/rubocop-rails/pull/1324
I wish Ruby had @foo |||= potentially_nil spikey rose memoisation just for that.
Thank you!