I love scaffolding, probably more than I should! It gets me playing with data right away and lets me put up a skeleton quickly. The nice thing about scaffolding with Phoenix (compared to Rails) is that less "cruft" is created. No extra css, coffee script, or fixtures created. Yay!
The special command for scaffolding is:
mix phx.gen.html Accounts User users name:string age:integer
mixis the sweet tool for running all your tasks
phx.gen.htmlis the namespaced module containing the generation code
Accountsis your context, the "group" or "collection" it belongs to.
Useris the name of the module that contains your schema and changeset
usersis the name of your database table
The following attributes are avaliable:
:datetime- An alias for
I find the
references option to be interesting, used like:
Oh? You just want to generate the schema and not the html? Then use this command:
mix phx.gen.schema Accounts.User users name:string age:integer
Written by Alan Vardy. Let me know how I can make this better!