Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Generating a resource does not work for the resource name "pepsi" #1909

Closed
Maidomax opened this issue Feb 22, 2020 · 2 comments
Closed

Generating a resource does not work for the resource name "pepsi" #1909

Maidomax opened this issue Feb 22, 2020 · 2 comments

Comments

@Maidomax
Copy link

Description

If you generate a "pepsi" resource with buffalo generate resource pepsi, some routes are not named properly (some are "pepsi/pepsis", some are "pepse/pepses"):

METHOD PATH NAME HANDLER
GET / rootPath dummyapp/actions.HomeHandler
GET /pepsis/ pepsisPath dummyapp/actions.PepsisResource.List
POST /pepsis/ pepsisPath dummyapp/actions.PepsisResource.Create
GET /pepsis/new/ newPepsisPath dummyapp/actions.PepsisResource.New
GET /pepsis/{pepse_id}/ pepsePath dummyapp/actions.PepsisResource.Show
PUT /pepsis/{pepse_id}/ pepsePath dummyapp/actions.PepsisResource.Update
DELETE /pepsis/{pepse_id}/ pepsePath dummyapp/actions.PepsisResource.Destroy
GET /pepsis/{pepse_id}/edit/ editPepsePath dummyapp/actions.PepsisResource.Edit

You can see the same problems in some variable names in pepsis.go action:

// List gets all Pepsis. This function is mapped to the path
// GET /pepsis
func (v PepsisResource) List(c buffalo.Context) error {
  // Get the DB connection from the context
  tx, ok := c.Value("tx").(*pop.Connection)
  if !ok {
    return fmt.Errorf("no transaction found")
  }

  pepses := &models.Pepsis{}

Steps to Reproduce the Problem

  1. Generate a new app with buffalo new dummyapp and cd into the app's folder
  2. Generate the resource with buffalo generate resource pepsi
  3. Start the app and check the home page

Expected Behavior

I expect the app not to break

Actual Behavior

It does

Info

-> Go: Checking installation
✓ The `go` executable was found on your system at: /snap/bin/go

-> Go: Checking minimum version requirements
✓ Your version of Go, 1.13.4, meets the minimum requirements.

-> Go: Checking GOPATH
✓ You are using Go Modules, so no need to worry about the GOPATH.

-> Go: Checking Package Management
✓ You are using Go Modules (`go`) for package management.

-> Go: Checking PATH
✓ Your PATH contains /home/mladen/go/bin.

-> Node: Checking installation
✓ The `node` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/node

-> Node: Checking minimum version requirements
✓ Your version of Node, v13.5.0, meets the minimum requirements.

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/npm

-> NPM: Checking minimum version requirements
✓ Your version of NPM, 6.13.7, meets the minimum requirements.

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /home/mladen/.nvm/versions/node/v13.5.0/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.21.1, meets the minimum requirements.

-> PostgreSQL: Checking installation
✘ The `postgres` executable could not be found on your system.
For help setting up your Postgres environment please follow the instructions for you platform at:

https://www.postgresql.org/download/

-> MySQL: Checking installation
✓ The `mysql` executable was found on your system at: /usr/bin/mysql

-> MySQL: Checking minimum version requirements
✓ Your version of MySQL, 14.14, meets the minimum requirements.

-> SQLite3: Checking installation
✓ The `sqlite3` executable was found on your system at: /usr/bin/sqlite3

-> SQLite3: Checking minimum version requirements
✓ Your version of SQLite3, 3.22.0, meets the minimum requirements.

-> Cockroach: Checking installation
✘ The `cockroach` executable could not be found on your system.
For help setting up your Cockroach environment please follow the instructions for you platform at:

https://www.cockroachlabs.com/docs/stable/

-> Buffalo (CLI): Checking installation
✓ The `buffalo` executable was found on your system at: /usr/local/bin/buffalo

-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.15.3, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /home/mladen/Projects/BuffaloTest/dummyapp
Root        /home/mladen/Projects/BuffaloTest/dummyapp
GoPath      /home/mladen/go
PackagePkg  dummyapp
ActionsPkg  dummyapp/actions
ModelsPkg   dummyapp/models
GriftsPkg   dummyapp/grifts
WithModules true
Name        dummyapp
Bin         bin/dummyapp
VCS         git
WithPop     true
WithSQLite  false
WithDep     false
WithWebpack true
WithNodeJs  true
WithYarn    true
WithDocker  true
WithGrifts  true
AsWeb       true
AsAPI       false
InApp       true
PackageJSON {map[build:webpack -p --progress dev:webpack --watch]}

-> Buffalo: config/buffalo-app.toml
name = "dummyapp"
bin = "bin/dummyapp"
vcs = "git"
with_pop = true
with_sqlite = false
with_dep = false
with_webpack = true
with_nodejs = true
with_yarn = true
with_docker = true
with_grifts = true
as_web = true
as_api = false

-> Buffalo: config/buffalo-plugins.toml
[[plugin]]
  binary = "buffalo-pop"
  go_get = "github.com/gobuffalo/buffalo-pop"

-> Buffalo: go.mod
module dummyapp

go 1.13

require (
	github.com/gobuffalo/buffalo v0.15.3
	github.com/gobuffalo/buffalo-pop v1.23.1
	github.com/gobuffalo/envy v1.8.1
	github.com/gobuffalo/mw-csrf v0.0.0-20190129204204-25460a055517
	github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
	github.com/gobuffalo/mw-i18n v0.0.0-20190129204410-552713a3ebb4
	github.com/gobuffalo/mw-paramlogger v0.0.0-20190129202837-395da1998525
	github.com/gobuffalo/packr/v2 v2.7.1
	github.com/gobuffalo/pop v4.13.1+incompatible
	github.com/gobuffalo/suite v2.8.2+incompatible
	github.com/gobuffalo/validate v2.0.3+incompatible
	github.com/gofrs/uuid v3.2.0+incompatible
	github.com/markbates/grift v1.5.0
	github.com/stretchr/testify v1.4.0
	github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
)

@markbates
Copy link
Member

duplicate of gobuffalo/flect#37

@Maidomax
Copy link
Author

duplicate of gobuffalo/flect#37

I couldn't find the original one, I thought I forgot to post it. My bad. Sorry.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants