Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Scaffold generates broken code on 0.6.13 #269

Closed
mistermojo opened this Issue Nov 20, 2012 · 6 comments

Comments

Projects
None yet
3 participants

Something broke scaffold's generated code. To replicate:

$ geddy app testapp
$ cd testapp
$ geddy scaffold thingie title:string abc:int
$ geddy

In browser, go to localhost:4000/thingies

/usr/lib/node_modules/geddy/lib/template/engines/ejs.js:74
    throw err;
          ^
ReferenceError: ejs:3
    1| <div class="hero-unit">
    2|   <h2>All Thingies</h2>
 >> 3|   <%- linkTo('Create a new Thingie', addThingiePath, {class: 'btn pull-right'}); %>
    4| </div>
    5| 
    6| <div id="thingies-list">
addThingiePath is not defined
    at Template.handleErr (/usr/lib/node_modules/geddy/lib/template/engines/ejs.js:58:15)
    at Object.Template.compile.rethrow (/usr/lib/node_modules/geddy/lib/template/engines/ejs.js:90:41)
    at eval (eval at <anonymous> (/usr/lib/node_modules/geddy/lib/template/engines/ejs.js:88:10))
    at Template.compile (/usr/lib/node_modules/geddy/lib/template/engines/ejs.js:99:17)
    at ejs.render (/usr/lib/node_modules/geddy/lib/template/adapters/ejs.js:28:10)
    at Adapter.render (/usr/lib/node_modules/geddy/lib/template/adapters/index.js:122:22)
    at engine.TemplateNode.loadTemplate.handleLoaded (/usr/lib/node_modules/geddy/lib/template/template_node.js:110:35)
    at engine.TemplateNode.loadTemplate (/usr/lib/node_modules/geddy/lib/template/template_node.js:136:7)
    at fs.readFile (fs.js:176:14)
    at Object.oncomplete (fs.js:297:15)
[Tue, 20 Nov 2012 07:57:44 GMT] ERROR Worker 2607 died.

I then tried (in the same app) to do

$ geddy scaffold blob title:string foo:string

Everything OK with http://locahost:4000/blobs

Contributor

larzconwell commented Nov 20, 2012

It seems the helper was generated incorrectly, I'm looking into it now. It should have been called addThingyPath which you can replace and it'll work correctly for you.

Contributor

larzconwell commented Nov 20, 2012

The problem is the way you spelled "thingie" it should have been spelled "thingy" and the plural is "thingies", so I'm gonna change the generator so it will fix misspellings like that automatically.

The only reason this is a problem is because when we run the generator with the misspelled version it writes all that to the templates, then when we start the application it generates the action helpers from the plural controller name it fixes the misspelling when we create the inflections.

larzconwell added a commit to mde/utilities that referenced this issue Nov 20, 2012

Closes geddy/geddy#269 Attempt to fix incorrect misspellings
automatically by changing it to it's plural version first and using that
to generate it's inflections.

Example:
thingie vs thingy

Also included a function callback check in string#truncate, because
Handlebars like to include a third argument for no apparent reason.
Contributor

larzconwell commented Nov 20, 2012

Hopefully the commit above will fix your problems (:

Please correct me if I'm wrong but I hope you don't actually mean geddy will correct my nouns automatically despite my conscious intent? What if I actually wanted "geddy scaffold thingie"? Would that still work? There are English words that end in -ie and the plural is just -ies (eg. valkyrie, zombie, freebie) As there are singular nouns that end in -y but pluralize to -ys (eg. day, monkey).

Honestly, if geddy tried to fix nouns like these automatically, it may cause more surprising (esp. to the newbie user) breakage in the future. Coding-in the exceptions would be onerous. Especially when there are English words that have exact same plural and singular forms (eg. salmon, sheep, deer) and not to mention words like locus-loci, phenomenon-phenomena, bacterium-bacteria, ox-oxen (but box-boxes!).

Thus, I would propose that a note be placed in the documentation about this geddy behaviour and perhaps add an optional argument for users to specify the plural form of the word. Perhaps: "geddy resource monkey:monkeys", "geddy resource salmon:salmon" (problematic?). If the ":" char is disliked due to property type usage, then perhaps another char: "%" or "@" or "+" or even "&"?

Anyway, thanks for looking into this, larzconwell. 👍

Contributor

mde commented Nov 20, 2012

Agree we don't want to overcompensate into "Clippy" territory trying to fix
things for people. Can we revert this change for now?

I really do like the idea of giving people the ability to override the
pluralization (I know Rails does this), but that's a bigger project that
will involve touching lots of places throughout the codebase. Here's the
ticket for it:

mde#270

On Tue, Nov 20, 2012 at 12:45 PM, mistermojo notifications@github.comwrote:

I hope you don't actually mean geddy will correct my nouns automatically
despite my conscious intent? What if I actually wanted "geddy scaffold
thingie"? Would that still work? There are English words that end in -ie
and the plural is just -ies (eg. valkyrie, zombie, freebie) As there are
singular nouns that end in -y but pluralize to -ys (eg. day, monkey).

Honestly, if geddy tried to fix nouns like these automatically, it may
cause more surprising (esp. to the newbie user) breakage in the future.
Coding-in the exceptions would be onerous. Especially when there are
English words that have exact same plural and singular forms (eg. salmon,
sheep, deer) and not to mention locus-loci, phenomenon-phenomena,
bacterium-bacteria, ox-oxen (but box-boxes!).

Thus, I would propose that a note be placed in the documentation about
this geddy behaviour and perhaps add an optional argument for users to
specify the plural form of the word. Perhaps: "geddy resource
monkey:monkeys", "geddy resource salmon:salmon" (problematic?). If the ":"
char is disliked due to property type usage, then perhaps another char: "%"
or "@" or "+" or even "&"?

Anyway, thanks for looking into this, larzconwell. [image: 👍]


Reply to this email directly or view it on GitHubhttps://github.com/mde/geddy/issues/269#issuecomment-10572190.

Contributor

larzconwell commented Nov 20, 2012

Yeah that is true, thanks for the insight @mistermojo. Did you revert it @mde?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment