Skip to content

Files

Latest commit

 

History

History
29 lines (19 loc) · 648 Bytes

Rails-FindBy.md

File metadata and controls

29 lines (19 loc) · 648 Bytes

Pattern: Use of where.first instead of find_by

Issue: -

Description

This rule is used to identify usages of where.first and change them to use find_by instead.

Examples

# bad
User.where(name: 'Bruce').first
User.where(name: 'Bruce').take

# good
User.find_by(name: 'Bruce')

Default configuration

Attribute Value
Include app/models/**/*.rb

Further Reading