This article is a walk through of basics for developing with the Gobuffalo.io framework.
- gobufalo installed successfully
- you're run
buffalo plugins list
and seenbuffalo pop
is installed - go version go1.11.5 darwin/amd64 (running on MAC OSX)
- Buffalo version is: v0.14.6
- Run
buffalo new <app name> --db-type=<db name>
. - Open
<app name>
directory in favorite editor. - Open
database.yml
in your editor. - Modify settings to match authentication, port and database schema requirements for
dev
andtest
. - Run
buffalo db create
. This will create the database for you locally. - With this successfully run, I recommend
git add && git commit -m "init commit"
. - Ok, now run
buffalo dev
. - Open
http://localhost:3000
to view app succesfully running. You should see theroutes
page listing currently specified routes.
At this point you have a running gobuffalo
application running locally.
Now let's modify our application to add CRUD operations for an entity.
- Run
buffalo g resource <resource name>
(could be users etc.).- notice how it creates migrations, actions, models and templates.
- Example:
buffalo generate resource widget title description:nulls.Text
will generate migrations, actions, models and templates plus attributes.
- Run
buffalo db migrate up
. This will modify the database. - Restart your application. (kill process then run
buffalo dev
) - Now, test your new resource by opening
http://localhost:3000/<resource name>/
(http://localhost:3000/widgets/ will show the index page for widgets) - Create a new
<resource name>
orwidget
to test persistence. If successful, you're off to the races! Be sure to commit changes and push.