Skip to content

Files

Latest commit

 

History

History
40 lines (26 loc) · 756 Bytes

Rails-DynamicFindBy.md

File metadata and controls

40 lines (26 loc) · 756 Bytes

Pattern: Use of dynamic find_by_*

Issue: -

Description

This rule checks dynamic find_by_* methods. Use find_by instead of dynamic method.

Examples

# bad
User.find_by_name(name)

# bad
User.find_by_name_and_email(name)

# bad
User.find_by_email!(name)

# good
User.find_by(name: name)

# good
User.find_by(name: name, email: email)

# good
User.find_by!(email: email)

Default configuration

Attribute Value
Whitelist find_by_sql

Further Reading