aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_basics.md
diff options
context:
space:
mode:
authorCristian Planas <me@cristianplanas.com>2013-07-01 01:38:46 +0200
committerCristian Planas <me@cristianplanas.com>2013-07-01 01:38:46 +0200
commit93fd780a882555f6ae369ca5a445a47568bc5f1a (patch)
treebc618ab490989b25443ef0d75189c0f8ee71568c /guides/source/active_record_basics.md
parent6e583cdac30332f10c73bec4fe3e857b7cdb9975 (diff)
downloadrails-93fd780a882555f6ae369ca5a445a47568bc5f1a.tar.gz
rails-93fd780a882555f6ae369ca5a445a47568bc5f1a.tar.bz2
rails-93fd780a882555f6ae369ca5a445a47568bc5f1a.zip
Using preferred find_by syntax in guides
Diffstat (limited to 'guides/source/active_record_basics.md')
-rw-r--r--guides/source/active_record_basics.md8
1 files changed, 4 insertions, 4 deletions
diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md
index 1f25c6ae95..d9fb20f3bf 100644
--- a/guides/source/active_record_basics.md
+++ b/guides/source/active_record_basics.md
@@ -253,7 +253,7 @@ user = User.first
```ruby
# return the first user named David
-david = User.find_by_name('David')
+david = User.find_by(name: 'David')
```
```ruby
@@ -270,7 +270,7 @@ Once an Active Record object has been retrieved, its attributes can be modified
and it can be saved to the database.
```ruby
-user = User.find_by_name('David')
+user = User.find_by(name: 'David')
user.name = 'Dave'
user.save
```
@@ -279,7 +279,7 @@ A shorthand for this is to use a hash mapping attribute names to the desired
value, like so:
```ruby
-user = User.find_by_name('David')
+user = User.find_by(name: 'David')
user.update(name: 'Dave')
```
@@ -297,7 +297,7 @@ Likewise, once retrieved an Active Record object can be destroyed which removes
it from the database.
```ruby
-user = User.find_by_name('David')
+user = User.find_by(name: 'David')
user.destroy
```