April 2016
Beginner to intermediate
300 pages
6h 58m
English
Now that we have in-memory annotations going across all connected clients through an authenticated user, let’s create an Annotation model. You’ve seen how we manage models and relationships with Ecto. In this case, we’re creating annotations on videos. Each new annotation will belong to both a user and a video.
You can use the phoenix.gen.model generator, like this:
| | $ mix phoenix.gen.model Annotation annotations body:text at:integer \ |
| | user_id:references:users video_id:references:videos |
| | |
| | * creating priv/repo/migrations/20150921162814_create_annotation.exs |
| | * creating web/models/annotation.ex |
| | * creating test/models/annotation_test.exs |
| | |
| | $ |
And now you can migrate our database: