Getting error using belongs_to in Ecto phoenix.gen.html

I am creating a model that I want to create in relation to my user model. Following http://www.phoenixframework.org/v0.13.1/docs/ecto-models#section-data-relationship-and-dependencies , the phoenix.gen.html file is used as follows:

W:runcible>mix phoenix.gen.html Ansible ansibles ansible_name:string ansible_description:text user:belongs_to 

But I get the following when I run it.

 Compiled web/models/user.ex Compiled web/controllers/user_controller.ex Generated runcible app ** (Mix) Unknown type `belongs_to` given to generator 

Any ideas I made a mistake?

+5
source share
1 answer

You are viewing the old version (0.13) of the documentation.

Starting with Phoenix 0.16 This should be:

 mix phoenix.gen.model Video videos name:string approved_at:datetime description:text likes:integer views:integer user_id:references:users 

Note:

 user_id:references:users 

instead:

 user:belongs_to 

Here is a link to the latest docs .

+11
source

Source: https://habr.com/ru/post/1234806/


All Articles