phoenix-framework Getting started with phoenix-framework Generating resources for a model


Example

To generate schema, view, controller, migration file for the repository, default CRUD templates and test files for a model (like a scaffolding in Rails) one can use phoenix.gen.html mix task like this:

mix phoenix.gen.html Book books title note:text pages:integer author_id:references:authors

Where Book is the module name, books is plural form used for schema, followed by resource fields: title (string by default), note (text field), pages (integer), author_id which creates a belongs_to association with the Author model.