Skip to content

Camel Case models break scaffolded views in coffee mode #4

@NeilBryant

Description

@NeilBryant

I need a table for 'packages'. Initializing with --coffee, it won't let me make that table, saying it's a reserved word. It will create it happily if the project is javascript, but I want coffee, and I don't see a NOT coffee switch for the scaffolding.

So I renamed it 'appPackage', trying to stick to javascripty formatting.

That breaks the view--at least, the add view, with:

12| h1 New apppackage
13|
> 14| - var form = formFor(apppackage, {action: pathTo.apppackages(), method: 'POST', id: "apppackage_form", class: 'form-horizontal'})
15|
16| != form.begin()
17| include _form

It looks like the schema and models are keeping the CamelCase, but the views are lowercasing everything?

---- Comment from Anatoliy ----
There's no way to correct this behavior currently using generators. But I
agree this makes life harder sometimes. To fix it need to come up with some
naming convention in model/crud generator. For example always assume model
is camelCase singular word. And then just produce all forms used in app:
lowerCase first camelcase singular for instance name, upperCase first
camelcase singilar for class name, lowerCase first plural for collections.
It also may require some fixes in routing helpers generators. Probably it
worth opening issue in co-generators package.

---- Comment from Neil ----
There's never going to be a way to always get automated plurals and casing correct; there're just too many mutations. It might be simpler in other languages, but English at least is about 90% edge-cases.

I would vote for the above (assume camelCase singular), but possibly with override options (-plural xxxx). .NET uses a -tablename option. -collection, or similar might be good options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions