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

[Bug] buffalo grenerate resource wrong template path #1769

Closed
Tracked by #2332
badstorm opened this issue Aug 18, 2019 · 7 comments
Closed
Tracked by #2332

[Bug] buffalo grenerate resource wrong template path #1769

badstorm opened this issue Aug 18, 2019 · 7 comments
Assignees
Labels
bug Something isn't working s: accepted was accepted or confirmed
Milestone

Comments

@badstorm
Copy link

Description

If I create a new resource with this nomencalture NameOthername, the generation command create in the template folder a direcotry "name" with inside a subdirectory "othername" and inside all the html files.
But If I try to connect to one of the action of this resource, buffalo try to find the template in other path "name_othername/file.html"

Steps to Reproduce the Problem

Crate a resource withj two uppercase letters:

$ buffalo g r NameOthername title description
$ buffalo pop migrate up
$ buffalo dev

Expected Behavior

Access to the resource paths

Actual Behavior

Actualy you get an error in anyone of the resources paths:
name_othername/index.html: could not find template name_othername/index.html

Info

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

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

-> Go: Checking GOPATH
✓ You appear to be operating inside of your GOPATH.

-> Go: Checking Package Management
⚠ You do not appear to be using a package management system.

It is strongly suggested that you use one of the following package management systems:

* Go Modules (Recommended) - https://gobuffalo.io/en/docs/gomods
* Dep - https://github.com/golang/dep

For help setting up your Go environment please follow the instructions for you platform at:

https://www.gopherguides.com/courses/preparing-your-environment-for-go-development

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

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

-> Node: Checking minimum version requirements
✓ Your version of Node, v10.16.2, meets the minimum requirements.

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

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

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

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.17.3, 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 could not be found on your system.
For help setting up your MySQL environment please follow the instructions for you platform at:

https://www.mysql.com/downloads/

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

https://www.sqlite.org/download.html

-> 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: Checking installation
✓ The `buffalo` executable was found on your system at: /usr/local/bin/buffalo

-> Buffalo: Checking minimum version requirements
✓ Your version of Buffalo, v0.14.9, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /home/badstorm/go/src/duckpage.com/rde01
Root        /home/badstorm/go/src/duckpage.com/rde01
GoPath      /home/badstorm/go
PackagePkg  duckpage.com/rde01
ActionsPkg  duckpage.com/rde01/actions
ModelsPkg   duckpage.com/rde01/models
GriftsPkg   duckpage.com/rde01/grifts
WithModules false
Name        rde01
Bin         bin/rde01
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[]}

-> Buffalo: config/buffalo-app.toml
name = "rde01"
bin = "bin/rde01"
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-auth"
  go_get = "github.com/gobuffalo/buffalo-auth"

[[plugin]]
  binary = "buffalo-pop"
  go_get = "github.com/gobuffalo/buffalo-pop"
@stanislas-m stanislas-m added the s: triage Some tests need to be run to confirm the issue label Aug 21, 2019
@tobiashienzsch
Copy link
Contributor

The problem seems to be in genny/resource/resource.go:48

In the example from @badstorm pres.Name.String() still returns the expected NameOthername, but pres.Name.Folder().String() returns name/othername

@tobiashienzsch
Copy link
Contributor

After a little more research, it seems like the error is in gobuffalo/flect. I opened an issue, see here

@GaelFG
Copy link

GaelFG commented Jun 11, 2020

It doesn't resolve this issue specifically, but it seems the correct nomenclature to use with the command is using snake case with singular in resource name.
It does automatically generate :
a database table with a plural snake_case name.
a model file name with singular snake
a go type with singular PascalCase name
a go type for the collection with a plural PascalCase name
and correct templates, actions and migration files.

In your case use the generator command :

buffalo generate resource name_othername and everything should work 'as intended'

@github-actions
Copy link

github-actions bot commented Aug 7, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@sio4 sio4 added bug Something isn't working s: accepted was accepted or confirmed and removed no-issue-activity labels Sep 3, 2022
@sio4 sio4 reopened this Sep 3, 2022
@sio4 sio4 self-assigned this Sep 3, 2022
@sio4 sio4 removed the s: triage Some tests need to be run to confirm the issue label Sep 3, 2022
@sio4
Copy link
Member

sio4 commented Sep 3, 2022

The root cause of this issue was just addressed in gobuffalo/flect#60 applying it to the stack is on the work.

(duplicated issue: gobuffalo/flect#12)

@sio4 sio4 added this to the v1.1.0 milestone Sep 26, 2022
@sio4 sio4 mentioned this issue Sep 27, 2022
11 tasks
@sio4
Copy link
Member

sio4 commented Sep 28, 2022

Now it works find. closeing.

@sio4 sio4 closed this as completed Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working s: accepted was accepted or confirmed
Projects
None yet
Development

No branches or pull requests

5 participants