-
-
Notifications
You must be signed in to change notification settings - Fork 574
Add basic functions into the default implementation of resource functions #297
Comments
It'll be cleaner if you use the new(ish) ValidateAnd... methods https://godoc.org/github.com/markbates/pop#Connection.ValidateAndCreate |
This probably better code to model after https://github.com/gobuffalo/toodo/blob/master/actions/todos.go |
Inside the documentation it is not defined how to use the resources generator for longer named models. For one word models that is clear, but whats with longer model names. For example a model How should the user generate that resource?
or should the generator support all possibilities? |
I would think it should be able to support any of those possibilities. |
I am moving forward. Now I need feedback, because I am not sure if I am on the right track. The following file is completely generated via Not all functions are completed so the status is WIP. The code compiles and works, when the template files exist. I added some comments to make that code easier to edit. Is this too much? or should there be much more comments? Something different: I don't know how to solve this: That is because inside the template following does not work
|
Wow! This is looking really good so far! Very impressed! To answer the last question first, you need to escape the https://github.com/markbates/pop/blob/master/soda%2Fcmd%2Fgenerate%2Fconfig_templates.go#L12 It's ugly, but that's just how you do it. :( I'm all for comments in the generated code, the more the merrier! The only comment I'll make at this stage (knowing that this is WIP), is to use the model name as the variable name. Right now you have this: t := &models.Page{} I would make it: page := &models.Page{} In addition to generating the corresponding tests, I would generate, at the very least "stub" HTML pages for each action. If you want to get really crazy you can implement the form pages using https://github.com/gobuffalo/tags, but it would be enough to start with just having simple HTML pages like: <h1>Pages#Show</h1>
Find me in templates/pages/show.html |
The generator for resources should generate some more code into the default implementations. The command
buffalo g r users
should add a basic functionality for the modeluser
.The generated code should be similar like in the html-resource example. But I would suggest not to use a middleware inside the generated code, because of readability issues.
The text was updated successfully, but these errors were encountered: