Skip to content

Commit 3fb6483

Browse files
authored
a bit more serializers
1 parent 682206c commit 3fb6483

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ You can see that a new directory was made in the ```app/``` directory and we now
394394
Let's open that file and see what we have:
395395
```ruby
396396
class MovieSerializer < ActiveModel::Serializer
397-
attributes :id
397+
attributes :id, :name
398398
end
399399
400400
```
@@ -403,16 +403,19 @@ We have our Movie Class inheriting from the serializer class on the first line,
403403
404404
1a. Turn on your rails server and go to the url ``` localhost:3000/api/v1/movies ```
405405
406-
You should see that only the ```id``` attribute is being returned from the database.
406+
You should see that only the ```id``` and ```name``` attribute is being returned from the database.
407407
```json
408408
{
409-
id: 1
409+
id: 1,
410+
name: "A Quiet Place"
410411
},
411412
{
412-
id: 2
413+
id: 2
414+
name: "The Avengers
413415
},
414416
{
415-
id: 3
417+
id: 3
418+
name: "Midsommar"
416419
}
417420
```
418421

0 commit comments

Comments
 (0)