Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error using 'belongs_to' in Ecto phoenix.gen.html

I'm making an model that I want to create in relationship to my user model. Following from http://www.phoenixframework.org/v0.13.1/docs/ecto-models#section-data-relationship-and-dependencies used the phoenix.gen.html 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 where I've made a mistake?

like image 344
Peter McCanney Avatar asked Oct 29 '15 15:10

Peter McCanney


1 Answers

You are looking at an old version (0.13) of the documentation.

As of Phoenix 0.16 It 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 of:

user:belongs_to

Here is a link to the latest docs.

like image 169
Gazler Avatar answered Nov 19 '22 15:11

Gazler