Skip to content

Commit

Permalink
Merge pull request rubocop#170 from lucianosousa/patch-1
Browse files Browse the repository at this point in the history
Add a new bad option in find_by part
  • Loading branch information
bbatsov committed Mar 10, 2016
2 parents ca0d146 + ac2f308 commit 4ff99ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,17 @@ when you need to retrieve a single record by id.
```

* <a name="find_by"></a>
Favor the use of `find_by` over `where`
Favor the use of `find_by` over `where` and `find_by_attribute`
when you need to retrieve a single record by some attributes.
<sup>[[link](#find_by)]</sup>

```Ruby
# bad
User.where(first_name: 'Bruce', last_name: 'Wayne').first
# bad
User.find_by_first_name_and_last_name('Bruce', 'Wayne')
# good
User.find_by(first_name: 'Bruce', last_name: 'Wayne')
```
Expand Down

0 comments on commit 4ff99ad

Please sign in to comment.