gobuffalo / buffalo

Rapid Web Development w/ Go
http://gobuffalo.io
MIT License
8.08k stars 578 forks source link

Resource generator adds to many fields to template (v0.14.0-beta.2) #1540

Closed tobiashienzsch closed 5 years ago

tobiashienzsch commented 5 years ago

Description

I'm using the new beta. When generating a new resource with buffalo generate resource product brand title variant:nulls.Text the output of the html form is:

<%= f.InputTag("Product") %>
<%= f.InputTag("Brand") %>
<%= f.InputTag("Title") %>
<%= f.TextAreaTag("Variant", {rows: 10}) %>
<button class="btn btn-success" role="submit">Save</button>

Even though it shouldn't have the "Product" field. This issue also occurs when using different resource names, e.g. brand or stores

Steps to Reproduce the Problem

Expected Behavior

<%= f.InputTag("Brand") %>
<%= f.InputTag("Title") %>
<%= f.TextAreaTag("Variant", {rows: 10}) %>
<button class="btn btn-success" role="submit">Save</button>

Actual Behavior

See top

Info

``` ### Buffalo Version v0.14.0-beta.2 ### App Information Pwd=/home/tobante/go/src/github.com/tobiashienzsch/shoppinger_data_manager Root=/home/tobante/go/src/github.com/tobiashienzsch/shoppinger_data_manager GoPath=/home/tobante/go PackagePkg=github.com/tobiashienzsch/shoppinger_data_manager ActionsPkg=github.com/tobiashienzsch/shoppinger_data_manager/actions ModelsPkg=github.com/tobiashienzsch/shoppinger_data_manager/models GriftsPkg=github.com/tobiashienzsch/shoppinger_data_manager/grifts WithModules=true Name=shoppinger-data-manager Bin=bin/shoppinger-data-manager VCS=git WithPop=true WithSQLite=false WithDep=false WithWebpack=true WithNodeJs=false WithYarn=true WithDocker=false WithGrifts=false AsWeb=true AsAPI=false ### Go Version go version go1.11.4 linux/amd64 ### Go Env GOARCH="amd64" GOBIN="" GOCACHE="/home/tobante/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/tobante/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/tobante/go/src/github.com/tobiashienzsch/shoppinger_data_manager/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build414895849=/tmp/go-build -gno-record-gcc-switches" ### Node Version v10.15.0 ### NPM Version 6.4.1 ### Yarn Version 1.12.3 ### PostgreSQL Version PostgreSQL Not Found ### MySQL Version MySQL Not Found ### SQLite Version 3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2alt1 ### Dep Version could not find a Gopkg.toml file ### Dep Status could not find a Gopkg.toml file ### go.mod module github.com/tobiashienzsch/shoppinger_data_manager require ( github.com/codegangsta/negroni v1.0.0 // indirect github.com/gobuffalo/buffalo v0.14.0-beta.2 github.com/gobuffalo/buffalo-pop v1.4.0 github.com/gobuffalo/envy v1.6.11 github.com/gobuffalo/makr v1.1.5 // indirect github.com/gobuffalo/mw-csrf v0.0.0-20180802151833-446ff26e108b github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130 github.com/gobuffalo/mw-i18n v0.0.0-20181027200759-09e0c99be4d3 github.com/gobuffalo/mw-paramlogger v0.0.0-20181005191442-d6ee392ec72e github.com/gobuffalo/packr v1.21.9 github.com/gobuffalo/packr/v2 v2.0.0-rc.14 github.com/gobuffalo/pop v4.9.4+incompatible github.com/gobuffalo/suite v2.6.0+incompatible github.com/gobuffalo/uuid v2.0.5+incompatible github.com/gobuffalo/validate v2.0.3+incompatible github.com/jackc/pgx v3.3.0+incompatible // indirect github.com/jmoiron/sqlx v1.2.0 // indirect github.com/markbates/grift v1.0.5 github.com/pkg/errors v0.8.1 github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c ) ```
lukasschlueter commented 5 years ago

Should be caused by this line:

https://github.com/gobuffalo/buffalo/blob/3fb335f88cd9de1193c58598627848e362855a17/buffalo/cmd/generate/resource.go#L46

The resource name is args[0] and is also included in the attributes.

Changing the index to 1 should do it, but we could use some tests for the generated templates.

markbates commented 5 years ago

We have tests for the templates, what we lack is tests for CLI. A PR to add some of those would be awesome, and very much so welcome. :) On Jan 17, 2019, 4:36 AM -0500, Lukas Schlüter notifications@github.com, wrote:

Should be caused by this line: https://github.com/gobuffalo/buffalo/blob/3fb335f88cd9de1193c58598627848e362855a17/buffalo/cmd/generate/resource.go#L46 The resource name is args[0] and is also included in the attributes. Changing the index to 1 should do it, but we could use some tests for the generated templates. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

tobiashienzsch commented 5 years ago

@lukasschlueter @markbates

I could change the buggy line and make a PR, but I'm not sure if I'm able to create tests yet, still relatively new to GO.

markbates commented 5 years ago

A PR would be great. We need to come up with a good way of testing CLIs still. On Jan 17, 2019, 8:00 AM -0500, tobiashienzsch notifications@github.com, wrote:

@lukasschlueter @markbates I could change the buggy line and make a PR, but I'm not sure if I'm able to create tests yet, still relatively new to GO. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.